From d0a4483713d05b6c31a31eb15cfaedfc01fb3cf8 Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Fri, 15 Apr 2011 16:10:38 -0400 Subject: [PATCH] RUBY-265 fix OrderedHash#reject! --- lib/bson/ordered_hash.rb | 4 ++++ test/bson/ordered_hash_test.rb | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) 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