Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
4c0cddc9
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4c0cddc9
编写于
12月 10, 2013
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Bring back the valid_options class accessor
It is need in activerecord-deprecated_finders
上级
d0588a2e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
14 addition
and
9 deletion
+14
-9
activerecord/lib/active_record/associations/builder/association.rb
...ord/lib/active_record/associations/builder/association.rb
+9
-4
activerecord/lib/active_record/associations/builder/belongs_to.rb
...cord/lib/active_record/associations/builder/belongs_to.rb
+1
-1
activerecord/lib/active_record/associations/builder/collection_association.rb
...ive_record/associations/builder/collection_association.rb
+1
-1
activerecord/lib/active_record/associations/builder/has_many.rb
...record/lib/active_record/associations/builder/has_many.rb
+1
-1
activerecord/lib/active_record/associations/builder/has_one.rb
...erecord/lib/active_record/associations/builder/has_one.rb
+1
-1
activerecord/lib/active_record/associations/builder/singular_association.rb
...ctive_record/associations/builder/singular_association.rb
+1
-1
未找到文件。
activerecord/lib/active_record/associations/builder/association.rb
浏览文件 @
4c0cddc9
require
'active_support/core_ext/module/attribute_accessors'
# This is the parent Association class which defines the variables
# used by all associations.
#
...
...
@@ -16,7 +18,10 @@ class << self
end
self
.
extensions
=
[]
VALID_OPTIONS
=
[
:class_name
,
:class
,
:foreign_key
,
:validate
]
# TODO: This class accessor is needed to make activerecord-deprecated_finders work.
# We can move it to a constant in 5.0.
cattr_accessor
:valid_options
,
instance_accessor:
false
self
.
valid_options
=
[
:class_name
,
:class
,
:foreign_key
,
:validate
]
def
self
.
build
(
model
,
name
,
scope
,
options
,
&
block
)
extension
=
define_extensions
model
,
name
,
&
block
...
...
@@ -63,12 +68,12 @@ def self.macro
raise
NotImplementedError
end
def
self
.
valid_options
(
options
)
VALID_OPTIONS
+
Association
.
extensions
.
flat_map
(
&
:valid_options
)
def
self
.
build_
valid_options
(
options
)
self
.
valid_options
+
Association
.
extensions
.
flat_map
(
&
:valid_options
)
end
def
self
.
validate_options
(
options
)
options
.
assert_valid_keys
(
valid_options
(
options
))
options
.
assert_valid_keys
(
build_
valid_options
(
options
))
end
def
self
.
define_extensions
(
model
,
name
)
...
...
activerecord/lib/active_record/associations/builder/belongs_to.rb
浏览文件 @
4c0cddc9
...
...
@@ -4,7 +4,7 @@ def self.macro
:belongs_to
end
def
self
.
valid_options
(
options
)
def
self
.
build_
valid_options
(
options
)
super
+
[
:foreign_type
,
:polymorphic
,
:touch
,
:counter_cache
]
end
...
...
activerecord/lib/active_record/associations/builder/collection_association.rb
浏览文件 @
4c0cddc9
...
...
@@ -7,7 +7,7 @@ class CollectionAssociation < Association #:nodoc:
CALLBACKS
=
[
:before_add
,
:after_add
,
:before_remove
,
:after_remove
]
def
self
.
valid_options
(
options
)
def
self
.
build_
valid_options
(
options
)
super
+
[
:table_name
,
:before_add
,
:after_add
,
:before_remove
,
:after_remove
,
:extend
]
end
...
...
activerecord/lib/active_record/associations/builder/has_many.rb
浏览文件 @
4c0cddc9
...
...
@@ -4,7 +4,7 @@ def self.macro
:has_many
end
def
self
.
valid_options
(
options
)
def
self
.
build_
valid_options
(
options
)
super
+
[
:primary_key
,
:dependent
,
:as
,
:through
,
:source
,
:source_type
,
:inverse_of
,
:counter_cache
]
end
...
...
activerecord/lib/active_record/associations/builder/has_one.rb
浏览文件 @
4c0cddc9
...
...
@@ -4,7 +4,7 @@ def self.macro
:has_one
end
def
self
.
valid_options
(
options
)
def
self
.
build_
valid_options
(
options
)
valid
=
super
+
[
:order
,
:as
]
valid
+=
[
:through
,
:source
,
:source_type
]
if
options
[
:through
]
valid
...
...
activerecord/lib/active_record/associations/builder/singular_association.rb
浏览文件 @
4c0cddc9
...
...
@@ -2,7 +2,7 @@
module
ActiveRecord::Associations::Builder
class
SingularAssociation
<
Association
#:nodoc:
def
self
.
valid_options
(
options
)
def
self
.
build_
valid_options
(
options
)
super
+
[
:remote
,
:dependent
,
:primary_key
,
:inverse_of
]
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录