aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/dirty.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-18 13:43:31 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-18 13:43:31 -0700
commitea721d7027c16f64c47395546c67858060a273e3 (patch)
treee3eb8855e41610c491fbfd9757ae2ff7d49d45cf /activemodel/lib/active_model/dirty.rb
parentc542677310b7dbb205cf3bc24f74099ae929ca20 (diff)
downloadrails-ea721d7027c16f64c47395546c67858060a273e3.tar.gz
rails-ea721d7027c16f64c47395546c67858060a273e3.tar.bz2
rails-ea721d7027c16f64c47395546c67858060a273e3.zip
Don't calculate in-place changes on attribute assignment
When an attribute is assigned, we determine if it was already marked as changed so we can determine if we need to clear the changes, or mark it as changed. Since this only affects the `attributes_changed_by_setter` hash, in-place changes are irrelevant to this process. Since calculating in-place changes can be expensive, we can just skip it here. I also added a test for the only edge case I could think of that would be affected by this change.
Diffstat (limited to 'activemodel/lib/active_model/dirty.rb')
-rw-r--r--activemodel/lib/active_model/dirty.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/dirty.rb b/activemodel/lib/active_model/dirty.rb
index afba9bab0d..614bc6a5d8 100644
--- a/activemodel/lib/active_model/dirty.rb
+++ b/activemodel/lib/active_model/dirty.rb
@@ -189,6 +189,7 @@ module ActiveModel
def changes_include?(attr_name)
attributes_changed_by_setter.include?(attr_name)
end
+ alias attribute_changed_by_setter? changes_include?
# Removes current changes and makes them accessible through +previous_changes+.
def changes_applied # :doc: