diff --git a/lib/bson/ordered_hash.rb b/lib/bson/ordered_hash.rb index 21c4ad0..425942a 100644 --- a/lib/bson/ordered_hash.rb +++ b/lib/bson/ordered_hash.rb @@ -138,6 +138,10 @@ module BSON clone.delete_if(&block) end + def reject!(&block) + delete_if(&block) + end + def clear super @ordered_keys = [] diff --git a/test/bson/ordered_hash_test.rb b/test/bson/ordered_hash_test.rb index f642161..ae97840 100644 --- a/test/bson/ordered_hash_test.rb +++ b/test/bson/ordered_hash_test.rb @@ -187,6 +187,11 @@ class OrderedHashTest < Test::Unit::TestCase assert !new.keys.include?('z') end + def test_reject_bang + @oh.reject! { |k, v| k == 'z' } + assert !@ok.keys.include?('z') + end + def test_clone copy = @oh.clone assert copy.keys == @oh.keys @@ -194,7 +199,7 @@ class OrderedHashTest < Test::Unit::TestCase copy[:foo] = 1 assert copy.keys != @oh.keys end - + def test_dup oh2 = @oh.dup oh2['f'] = 9