Permalink
Browse files

Overrode Hash#nested_under_indifferent_access in HashWithIndifferentA…

…ccess

to return self.
  • Loading branch information...
1 parent 6887aed commit 3d6eafe32ed498784dba2b9782bbf7df47ebeb6b @azimux azimux committed Dec 11, 2011
@@ -16,6 +16,10 @@ def with_indifferent_access
dup
end
+ def nested_under_indifferent_access
+ self
+ end
+
def initialize(constructor = {})
if constructor.is_a?(Hash)
super()
@@ -121,6 +121,9 @@ def test_nested_under_indifferent_access
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

0 comments on commit 3d6eafe

Please sign in to comment.