diff options
author | kennyj <kennyj@gmail.com> | 2012-07-14 02:50:28 +0900 |
---|---|---|
committer | kennyj <kennyj@gmail.com> | 2012-07-14 02:50:28 +0900 |
commit | 6c7c89a9f29bb790d6bb17a0b4a8daa284fc2c07 (patch) | |
tree | a965fbd69f7f25f86ad4ef81e76a051157df81cd /activerecord/lib/active_record | |
parent | a734902e9a1c64dd36b0ff08db44707c9f870e17 (diff) | |
download | rails-6c7c89a9f29bb790d6bb17a0b4a8daa284fc2c07.tar.gz rails-6c7c89a9f29bb790d6bb17a0b4a8daa284fc2c07.tar.bz2 rails-6c7c89a9f29bb790d6bb17a0b4a8daa284fc2c07.zip |
Remove duplicated code in the AR::Store.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/store.rb | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/store.rb b/activerecord/lib/active_record/store.rb index d836acf18f..990a1b78ed 100644 --- a/activerecord/lib/active_record/store.rb +++ b/activerecord/lib/active_record/store.rb @@ -77,16 +77,8 @@ module ActiveRecord private def initialize_store_attribute(store_attribute) - case attribute = send(store_attribute) - when ActiveSupport::HashWithIndifferentAccess - # Already initialized. Do nothing. - when Hash - # Initialized as a Hash. Convert to indifferent access. - send :"#{store_attribute}=", attribute.with_indifferent_access - else - # Uninitialized. Set to an indifferent hash. - send :"#{store_attribute}=", ActiveSupport::HashWithIndifferentAccess.new - end + attr = send(store_attribute) + send :"#{store_attribute}=", IndifferentCoder.as_indifferent_hash(attr) unless attr.is_a?(HashWithIndifferentAccess) end class IndifferentCoder @@ -109,7 +101,7 @@ module ActiveRecord def self.as_indifferent_hash(obj) case obj - when ActiveSupport::HashWithIndifferentAccess + when HashWithIndifferentAccess obj when Hash obj.with_indifferent_access |