Permalink
Browse files

Override #store to be consistent with #[].

[#5775 state:resolved]

Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
  • Loading branch information...
1 parent 621df2a commit d80afed620dde5b9356c883ae187db2332d4c18e @andreacampi andreacampi committed with spastorino Oct 9, 2010
@@ -45,6 +45,8 @@ def []=(key, value)
regular_writer(convert_key(key), convert_value(value))
end
+ alias_method :store, :[]=
+
# Updates the instantized hash with values from the second:
#
# hash_1 = HashWithIndifferentAccess.new
@@ -316,6 +316,16 @@ def test_deep_merge_on_indifferent_access
assert_equal expected, hash_1
end
+ def test_store_on_indifferent_access
+ hash = HashWithIndifferentAccess.new
+ hash.store(:test1, 1)
+ hash.store('test1', 11)
+ hash[:test2] = 2
+ hash['test2'] = 22
+ expected = { "test1" => 11, "test2" => 22 }
+ assert_equal expected, hash
+ end
+
def test_reverse_merge
defaults = { :a => "x", :b => "y", :c => 10 }.freeze
options = { :a => 1, :b => 2 }

0 comments on commit d80afed

Please sign in to comment.