1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

refactor ActiveRecord's #become by simplifying code

This commit is contained in:
Diego Carrion 2015-06-10 13:03:44 -03:00
parent 1a82e20f08
commit a3bab772a8

View file

@ -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)