aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-07-13 10:58:54 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-07-13 10:58:54 -0700
commitfd9655c9dc9c96dc43cc6b22e64ec216db2fdfc0 (patch)
tree29ffaab2c7127d145ff2f47461ecc6146a328685 /activerecord
parentbf6d64cd933e97d27f4726370ba3c97a3d479ba1 (diff)
parent6c7c89a9f29bb790d6bb17a0b4a8daa284fc2c07 (diff)
downloadrails-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')
-rw-r--r--activerecord/lib/active_record/store.rb14
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