aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/persistence.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-10-02 09:35:30 -0400
committerSean Griffin <sean@seantheprogrammer.com>2015-10-02 09:37:31 -0400
commitede244e2367c7988fa02f5e3b956d88211bb5ade (patch)
tree0fc191c9a03d7684146a244bc0aecf20c44c3907 /activerecord/lib/active_record/persistence.rb
parentc80b114c45215e713711c018a1ed2e6b264c22f8 (diff)
downloadrails-ede244e2367c7988fa02f5e3b956d88211bb5ade.tar.gz
rails-ede244e2367c7988fa02f5e3b956d88211bb5ade.tar.bz2
rails-ede244e2367c7988fa02f5e3b956d88211bb5ade.zip
Build the `AttributeMutationTracker` lazily
For reads, we never need to construct this object. The double `defined?` check is to avoid errors in tests
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r--activerecord/lib/active_record/persistence.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 7b53f6e5a0..3f02f73a5a 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -211,7 +211,7 @@ module ActiveRecord
def becomes(klass)
became = klass.new
became.instance_variable_set("@attributes", @attributes)
- became.instance_variable_set("@mutation_tracker", @mutation_tracker)
+ became.instance_variable_set("@mutation_tracker", @mutation_tracker) if defined?(@mutation_tracker)
became.instance_variable_set("@changed_attributes", attributes_changed_by_setter)
became.instance_variable_set("@new_record", new_record?)
became.instance_variable_set("@destroyed", destroyed?)