Merge pull request #1109 from dlee/optimize_indifferent_access
Use dup to preserve previous behavior
This commit is contained in:
commit
a921cab621
|
@ -11,7 +11,7 @@ module ActiveSupport
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_indifferent_access
|
def with_indifferent_access
|
||||||
self
|
dup
|
||||||
end
|
end
|
||||||
|
|
||||||
def initialize(constructor = {})
|
def initialize(constructor = {})
|
||||||
|
|
|
@ -971,9 +971,10 @@ class HashToXmlTest < Test::Unit::TestCase
|
||||||
assert_nil hash_wia.default
|
assert_nil hash_wia.default
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_return_self_for_with_indifferent_access
|
def test_should_return_dup_for_with_indifferent_access
|
||||||
hash_wia = HashWithIndifferentAccess.new
|
hash_wia = HashWithIndifferentAccess.new
|
||||||
assert_equal hash_wia, hash_wia.with_indifferent_access
|
assert_equal hash_wia, hash_wia.with_indifferent_access
|
||||||
|
assert_not_same hash_wia, hash_wia.with_indifferent_access
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_copy_the_default_value_when_converting_to_hash_with_indifferent_access
|
def test_should_copy_the_default_value_when_converting_to_hash_with_indifferent_access
|
||||||
|
|
Loading…
Reference in New Issue