Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
2235f669
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,体验更适合开发者的 AI 搜索 >>
提交
2235f669
编写于
9月 27, 2017
作者:
A
Aaron Patterson
提交者:
GitHub
9月 27, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #30471 from dylanahsmith/remove-redundant-tracker
activerecord: Remove a redundant mutation tracker
上级
9c833ba3
c342d584
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
24 deletion
+10
-24
activerecord/lib/active_record/attribute_methods/dirty.rb
activerecord/lib/active_record/attribute_methods/dirty.rb
+9
-23
activerecord/lib/active_record/persistence.rb
activerecord/lib/active_record/persistence.rb
+1
-1
未找到文件。
activerecord/lib/active_record/attribute_methods/dirty.rb
浏览文件 @
2235f669
...
...
@@ -34,7 +34,7 @@ module Dirty
def
reload
(
*
)
super
.
tap
do
@mutations_before_last_save
=
nil
clear_mutation_trackers
@mutations_from_database
=
nil
@changed_attributes
=
ActiveSupport
::
HashWithIndifferentAccess
.
new
end
end
...
...
@@ -44,22 +44,21 @@ def initialize_dup(other) # :nodoc:
@attributes
=
self
.
class
.
_default_attributes
.
map
do
|
attr
|
attr
.
with_value_from_user
(
@attributes
.
fetch_value
(
attr
.
name
))
end
clear_mutation_trackers
@mutations_from_database
=
nil
end
def
changes_applied
# :nodoc:
@mutations_before_last_save
=
mutation_tracker
@mutations_from_database
=
AttributeMutationTracker
.
new
(
@attributes
)
@mutations_before_last_save
=
mutations_from_database
@changed_attributes
=
ActiveSupport
::
HashWithIndifferentAccess
.
new
forget_attribute_assignments
clear_mutation_trackers
@mutations_from_database
=
nil
end
def
clear_changes_information
# :nodoc:
@mutations_before_last_save
=
nil
@changed_attributes
=
ActiveSupport
::
HashWithIndifferentAccess
.
new
forget_attribute_assignments
clear_mutation_trackers
@mutations_from_database
=
nil
end
def
clear_attribute_changes
(
attr_names
)
# :nodoc:
...
...
@@ -75,7 +74,7 @@ def changed_attributes # :nodoc:
if
defined?
(
@cached_changed_attributes
)
@cached_changed_attributes
else
super
.
reverse_merge
(
mutation
_tracker
.
changed_values
).
freeze
super
.
reverse_merge
(
mutation
s_from_database
.
changed_values
).
freeze
end
end
...
...
@@ -90,7 +89,7 @@ def previous_changes # :nodoc:
end
def
attribute_changed_in_place?
(
attr_name
)
# :nodoc:
mutation
_tracker
.
changed_in_place?
(
attr_name
)
mutation
s_from_database
.
changed_in_place?
(
attr_name
)
end
# Did this attribute change when we last saved? This method can be invoked
...
...
@@ -183,26 +182,18 @@ def write_attribute_without_type_cast(attr_name, _)
result
end
def
mutation_tracker
unless
defined?
(
@mutation_tracker
)
@mutation_tracker
=
nil
end
@mutation_tracker
||=
AttributeMutationTracker
.
new
(
@attributes
)
end
def
mutations_from_database
unless
defined?
(
@mutations_from_database
)
@mutations_from_database
=
nil
end
@mutations_from_database
||=
mutation_tracker
@mutations_from_database
||=
AttributeMutationTracker
.
new
(
@attributes
)
end
def
changes_include?
(
attr_name
)
super
||
mutation
_tracker
.
changed?
(
attr_name
)
super
||
mutation
s_from_database
.
changed?
(
attr_name
)
end
def
clear_attribute_change
(
attr_name
)
mutation_tracker
.
forget_change
(
attr_name
)
mutations_from_database
.
forget_change
(
attr_name
)
end
...
...
@@ -227,11 +218,6 @@ def forget_attribute_assignments
@attributes
=
@attributes
.
map
(
&
:forgetting_assignment
)
end
def
clear_mutation_trackers
@mutation_tracker
=
nil
@mutations_from_database
=
nil
end
def
mutations_before_last_save
@mutations_before_last_save
||=
NullMutationTracker
.
instance
end
...
...
activerecord/lib/active_record/persistence.rb
浏览文件 @
2235f669
...
...
@@ -322,7 +322,7 @@ def destroy!
def
becomes
(
klass
)
became
=
klass
.
new
became
.
instance_variable_set
(
"@attributes"
,
@attributes
)
became
.
instance_variable_set
(
"@mutation
_tracker"
,
@mutation_tracker
)
if
defined?
(
@mutation_tracker
)
became
.
instance_variable_set
(
"@mutation
s_from_database"
,
@mutations_from_database
)
if
defined?
(
@mutations_from_database
)
became
.
instance_variable_set
(
"@changed_attributes"
,
attributes_changed_by_setter
)
became
.
instance_variable_set
(
"@new_record"
,
new_record?
)
became
.
instance_variable_set
(
"@destroyed"
,
destroyed?
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录