diff options
author | Diego Carrion <dc.rec1@gmail.com> | 2015-06-10 13:03:44 -0300 |
---|---|---|
committer | Diego Carrion <dc.rec1@gmail.com> | 2015-06-10 13:03:44 -0300 |
commit | a3bab772a86414b7c854995d36b0ab0bb12fd50a (patch) | |
tree | d646c9cb54fd6fa943fcca2344a6a18c776bfacb | |
parent | 1a82e20f084803d12480507c7ef00001a16b2916 (diff) | |
download | rails-a3bab772a86414b7c854995d36b0ab0bb12fd50a.tar.gz rails-a3bab772a86414b7c854995d36b0ab0bb12fd50a.tar.bz2 rails-a3bab772a86414b7c854995d36b0ab0bb12fd50a.zip |
refactor ActiveRecord's #become by simplifying code
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 3 |
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) |