aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/hash_with_indifferent_access.rb
diff options
context:
space:
mode:
authorDavid Lee <davidomundo@gmail.com>2011-05-08 02:21:06 -0700
committerDavid Lee <davidomundo@gmail.com>2011-05-08 03:40:51 -0700
commit099eb2b3fd9526e06c30b9878780f31091e011aa (patch)
treefc6e89f7a0459ff376af0d8535f4aa270bab5a46 /activesupport/lib/active_support/hash_with_indifferent_access.rb
parent30db3a82f653e7d7215e41bec525932cf5b17de1 (diff)
downloadrails-099eb2b3fd9526e06c30b9878780f31091e011aa.tar.gz
rails-099eb2b3fd9526e06c30b9878780f31091e011aa.tar.bz2
rails-099eb2b3fd9526e06c30b9878780f31091e011aa.zip
indifferent access should recurse Hash subclasses
This commit makes Hash subclasses convert to HWIA by default for nested objects of subclasses of Hash, but allows certain subclasses to prevent nested conversion by introducing Hash#nested_under_indifferent_access that subclasses can overwrite. ActiveSupport::OrderedHash is one such subclass that overwrites +nested_under_indifferent_access+, since implicitly converting it to HWIA would remove the ordering of keys and values in Ruby 1.8. This change is necessary because commit ce9456e broke nested indifferent access conversion for all subclasses of Hash.
Diffstat (limited to 'activesupport/lib/active_support/hash_with_indifferent_access.rb')
-rw-r--r--activesupport/lib/active_support/hash_with_indifferent_access.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb
index 79a0de7940..8ec4f6e09a 100644
--- a/activesupport/lib/active_support/hash_with_indifferent_access.rb
+++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb
@@ -140,8 +140,8 @@ module ActiveSupport
end
def convert_value(value)
- if value.class == Hash
- self.class.new_from_hash_copying_default(value)
+ if value.is_a? Hash
+ value.nested_under_indifferent_access
elsif value.is_a?(Array)
value.dup.replace(value.map { |e| convert_value(e) })
else