diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-07-13 10:58:54 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-07-13 10:58:54 -0700 |
commit | fd9655c9dc9c96dc43cc6b22e64ec216db2fdfc0 (patch) | |
tree | 29ffaab2c7127d145ff2f47461ecc6146a328685 /activerecord/lib/active_record | |
parent | bf6d64cd933e97d27f4726370ba3c97a3d479ba1 (diff) | |
parent | 6c7c89a9f29bb790d6bb17a0b4a8daa284fc2c07 (diff) | |
download | rails-fd9655c9dc9c96dc43cc6b22e64ec216db2fdfc0.tar.gz rails-fd9655c9dc9c96dc43cc6b22e64ec216db2fdfc0.tar.bz2 rails-fd9655c9dc9c96dc43cc6b22e64ec216db2fdfc0.zip |
Merge pull request #7045 from kennyj/remove_duplicated_code_20120714
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 |