Overrode Hash#nested_under_indifferent_access in HashWithIndifferentAccess

to return self.
This commit is contained in:
Miles Georgi
2011-12-11 12:59:59 -08:00
parent 6887aed31b
commit 3d6eafe32e
2 changed files with 7 additions and 0 deletions

View File

@@ -16,6 +16,10 @@ module ActiveSupport
dup
end
def nested_under_indifferent_access
self
end
def initialize(constructor = {})
if constructor.is_a?(Hash)
super()

View File

@@ -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