aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/persistence.rb
diff options
context:
space:
mode:
authorDiego Carrion <dc.rec1@gmail.com>2015-06-10 13:03:44 -0300
committerDiego Carrion <dc.rec1@gmail.com>2015-06-10 13:03:44 -0300
commita3bab772a86414b7c854995d36b0ab0bb12fd50a (patch)
treed646c9cb54fd6fa943fcca2344a6a18c776bfacb /activerecord/lib/active_record/persistence.rb
parent1a82e20f084803d12480507c7ef00001a16b2916 (diff)
downloadrails-a3bab772a86414b7c854995d36b0ab0bb12fd50a.tar.gz
rails-a3bab772a86414b7c854995d36b0ab0bb12fd50a.tar.bz2
rails-a3bab772a86414b7c854995d36b0ab0bb12fd50a.zip
refactor ActiveRecord's #become by simplifying code
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r--activerecord/lib/active_record/persistence.rb3
1 files changed, 1 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index 437ba31711..0a6e4ac0bd 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -211,8 +211,7 @@ module ActiveRecord
def becomes(klass)
became = klass.new
became.instance_variable_set("@attributes", @attributes)
- changed_attributes = @changed_attributes if defined?(@changed_attributes)
- became.instance_variable_set("@changed_attributes", changed_attributes || {})
+ became.instance_variable_set("@changed_attributes", attributes_changed_by_setter)
became.instance_variable_set("@new_record", new_record?)
became.instance_variable_set("@destroyed", destroyed?)
became.instance_variable_set("@errors", errors)