Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
6c7e6abf
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,发现更多精彩内容 >>
未验证
提交
6c7e6abf
编写于
5月 31, 2018
作者:
K
Kevin Deisz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ensure reflection_class_for is private
上级
ce337d17
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
36 deletion
+40
-36
activerecord/lib/active_record/reflection.rb
activerecord/lib/active_record/reflection.rb
+27
-24
activestorage/lib/active_storage/reflection.rb
activestorage/lib/active_storage/reflection.rb
+13
-12
未找到文件。
activerecord/lib/active_record/reflection.rb
浏览文件 @
6c7e6abf
...
...
@@ -13,34 +13,37 @@ module Reflection # :nodoc:
class_attribute
:aggregate_reflections
,
instance_writer:
false
,
default:
{}
end
def
self
.
create
(
macro
,
name
,
scope
,
options
,
ar
)
reflection
=
reflection_class_for
(
macro
).
new
(
name
,
scope
,
options
,
ar
)
options
[
:through
]
?
ThroughReflection
.
new
(
reflection
)
:
reflection
end
class
<<
self
def
create
(
macro
,
name
,
scope
,
options
,
ar
)
reflection
=
reflection_class_for
(
macro
).
new
(
name
,
scope
,
options
,
ar
)
options
[
:through
]
?
ThroughReflection
.
new
(
reflection
)
:
reflection
end
def
self
.
reflection_class_for
(
macro
)
case
macro
when
:composed_of
AggregateReflection
when
:has_many
HasManyReflection
when
:has_one
HasOneReflection
when
:belongs_to
BelongsToReflection
else
raise
"Unsupported Macro:
#{
macro
}
"
def
add_reflection
(
ar
,
name
,
reflection
)
ar
.
clear_reflections_cache
name
=
name
.
to_s
ar
.
_reflections
=
ar
.
_reflections
.
except
(
name
).
merge!
(
name
=>
reflection
)
end
end
def
self
.
add_reflection
(
ar
,
name
,
reflection
)
ar
.
clear_reflections_cache
name
=
name
.
to_s
ar
.
_reflections
=
ar
.
_reflections
.
except
(
name
).
merge!
(
name
=>
reflection
)
end
def
add_aggregate_reflection
(
ar
,
name
,
reflection
)
ar
.
aggregate_reflections
=
ar
.
aggregate_reflections
.
merge
(
name
.
to_s
=>
reflection
)
end
def
self
.
add_aggregate_reflection
(
ar
,
name
,
reflection
)
ar
.
aggregate_reflections
=
ar
.
aggregate_reflections
.
merge
(
name
.
to_s
=>
reflection
)
private
def
reflection_class_for
(
macro
)
case
macro
when
:composed_of
AggregateReflection
when
:has_many
HasManyReflection
when
:has_one
HasOneReflection
when
:belongs_to
BelongsToReflection
else
raise
"Unsupported Macro:
#{
macro
}
"
end
end
end
# \Reflection enables the ability to examine the associations and aggregations of
...
...
activestorage/lib/active_storage/reflection.rb
浏览文件 @
6c7e6abf
...
...
@@ -18,21 +18,22 @@ def macro
end
end
module
ReflectionExtension
def
reflection_class_for
(
macro
)
case
macro
when
:has_one_attached
HasOneAttachedReflection
when
:has_many_attached
HasManyAttachedReflection
else
super
end
end
module
ReflectionExtension
# :nodoc:
def
add_attachment_reflection
(
ar
,
name
,
reflection
)
ar
.
attachment_reflections
.
merge!
(
name
.
to_s
=>
reflection
)
end
private
def
reflection_class_for
(
macro
)
case
macro
when
:has_one_attached
HasOneAttachedReflection
when
:has_many_attached
HasManyAttachedReflection
else
super
end
end
end
module
ActiveRecordExtensions
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录