diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-05-30 09:05:18 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-05-30 09:05:18 -0700 |
commit | eb6cee9cf7fd7c22fe3190e2660eeefdd5ec651f (patch) | |
tree | a2a251144c74c86f840b4496a624d154b77264da /activerecord/lib/active_record/transactions.rb | |
parent | 8c77b0a086bb47ef7cd4b827460a51613f94094e (diff) | |
download | rails-eb6cee9cf7fd7c22fe3190e2660eeefdd5ec651f.tar.gz rails-eb6cee9cf7fd7c22fe3190e2660eeefdd5ec651f.tar.bz2 rails-eb6cee9cf7fd7c22fe3190e2660eeefdd5ec651f.zip |
Rename attribute related instance variables to better express intent
`@attributes` was actually used for `_before_type_cast` and friends,
while `@attributes_cache` is the type cast version (and caching is the
wrong word there, but I'm working on removing the conditionals around
that). I opted for `@raw_attributes`, because `_before_type_cast` is
also semantically misleading. The values in said hash are in the state
given by the form builder or database, so raw seemed to be a good word.
Diffstat (limited to 'activerecord/lib/active_record/transactions.rb')
-rw-r--r-- | activerecord/lib/active_record/transactions.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index 17d1ae1ba0..d733063f5a 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -347,7 +347,7 @@ module ActiveRecord @_start_transaction_state[:destroyed] = @destroyed end @_start_transaction_state[:level] = (@_start_transaction_state[:level] || 0) + 1 - @_start_transaction_state[:frozen?] = @attributes.frozen? + @_start_transaction_state[:frozen?] = @raw_attributes.frozen? end # Clear the new record state and id of a record. @@ -368,16 +368,16 @@ module ActiveRecord if transaction_level < 1 || force restore_state = @_start_transaction_state was_frozen = restore_state[:frozen?] - @attributes = @attributes.dup if @attributes.frozen? + @raw_attributes = @raw_attributes.dup if @raw_attributes.frozen? @new_record = restore_state[:new_record] @destroyed = restore_state[:destroyed] if restore_state.has_key?(:id) write_attribute(self.class.primary_key, restore_state[:id]) else + @raw_attributes.delete(self.class.primary_key) @attributes.delete(self.class.primary_key) - @attributes_cache.delete(self.class.primary_key) end - @attributes.freeze if was_frozen + @raw_attributes.freeze if was_frozen end end end |