aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/persistence.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-30 15:16:48 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-30 15:16:48 -0300
commite6331b0aa81db3b402f5c1857a0c56c00daf9960 (patch)
tree303a63cc4f10dee25c4321c29e99edfafa3f0e13 /activerecord/lib/active_record/persistence.rb
parentce348b9b213f339eaac13d4c86bd3f5648e60ef4 (diff)
parenteb6cee9cf7fd7c22fe3190e2660eeefdd5ec651f (diff)
downloadrails-e6331b0aa81db3b402f5c1857a0c56c00daf9960.tar.gz
rails-e6331b0aa81db3b402f5c1857a0c56c00daf9960.tar.bz2
rails-e6331b0aa81db3b402f5c1857a0c56c00daf9960.zip
Merge pull request #15427 from sgrif/sg-rename-attribute-ivars
Rename attribute related instance variables to better express intent
Diffstat (limited to 'activerecord/lib/active_record/persistence.rb')
-rw-r--r--activerecord/lib/active_record/persistence.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb
index b74e340b3e..78ae05073a 100644
--- a/activerecord/lib/active_record/persistence.rb
+++ b/activerecord/lib/active_record/persistence.rb
@@ -179,8 +179,8 @@ module ActiveRecord
# So any change to the attributes in either instance will affect the other.
def becomes(klass)
became = klass.new
+ became.instance_variable_set("@raw_attributes", @raw_attributes)
became.instance_variable_set("@attributes", @attributes)
- became.instance_variable_set("@attributes_cache", @attributes_cache)
became.instance_variable_set("@changed_attributes", @changed_attributes) if defined?(@changed_attributes)
became.instance_variable_set("@new_record", new_record?)
became.instance_variable_set("@destroyed", destroyed?)
@@ -396,11 +396,11 @@ module ActiveRecord
self.class.unscoped { self.class.find(id) }
end
- @attributes.update(fresh_object.instance_variable_get('@attributes'))
+ @raw_attributes.update(fresh_object.instance_variable_get('@raw_attributes'))
@column_types = self.class.column_types
@column_types_override = fresh_object.instance_variable_get('@column_types_override')
- @attributes_cache = {}
+ @attributes = {}
self
end
@@ -490,7 +490,7 @@ module ActiveRecord
# Updates the associated record with values matching those of the instance attributes.
# Returns the number of affected rows.
- def _update_record(attribute_names = @attributes.keys)
+ def _update_record(attribute_names = @raw_attributes.keys)
attributes_values = arel_attributes_with_values_for_update(attribute_names)
if attributes_values.empty?
0
@@ -501,7 +501,7 @@ module ActiveRecord
# Creates a record with values matching those of the instance attributes
# and returns its id.
- def _create_record(attribute_names = @attributes.keys)
+ def _create_record(attribute_names = @raw_attributes.keys)
attributes_values = arel_attributes_with_values_for_create(attribute_names)
new_id = self.class.unscoped.insert attributes_values