diff options
author | José Valim <jose.valim@gmail.com> | 2011-12-11 13:20:55 -0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-12-11 13:20:55 -0800 |
commit | a8f2b203b45bfa34785b3c411079e59f60c52cac (patch) | |
tree | d1b6b93a7c0f6c0260dd2e245c5670cbfe8e456d | |
parent | 6887aed31bc4f60bdc3291acd8a2a7a9bca206db (diff) | |
parent | 3d6eafe32ed498784dba2b9782bbf7df47ebeb6b (diff) | |
download | rails-a8f2b203b45bfa34785b3c411079e59f60c52cac.tar.gz rails-a8f2b203b45bfa34785b3c411079e59f60c52cac.tar.bz2 rails-a8f2b203b45bfa34785b3c411079e59f60c52cac.zip |
Merge pull request #3941 from azimux/fix_nested_under_indifferent_access
Overrode Hash#nested_under_indifferent_access in HashWithIndifferentAccess
-rw-r--r-- | activesupport/lib/active_support/hash_with_indifferent_access.rb | 4 | ||||
-rw-r--r-- | activesupport/test/core_ext/hash_ext_test.rb | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index 636f019cd5..674e4acfd6 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -16,6 +16,10 @@ module ActiveSupport dup end + def nested_under_indifferent_access + self + end + def initialize(constructor = {}) if constructor.is_a?(Hash) super() diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb index fa800eada2..eb8ed761da 100644 --- a/activesupport/test/core_ext/hash_ext_test.rb +++ b/activesupport/test/core_ext/hash_ext_test.rb @@ -121,6 +121,9 @@ class HashExtTest < Test::Unit::TestCase foo = { "foo" => NonIndifferentHash.new.tap { |h| h["bar"] = "baz" } }.with_indifferent_access assert_kind_of NonIndifferentHash, foo["foo"] + + foo = { "foo" => IndifferentHash.new.tap { |h| h["bar"] = "baz" } }.with_indifferent_access + assert_kind_of IndifferentHash, foo["foo"] end def test_indifferent_assorted |