RUBY-359 Fix for OrderedHash on 1.8.7

This commit is contained in:
Kyle Banker 2011-11-15 12:43:29 -05:00
parent 6f57665631
commit 24b9653366
2 changed files with 6 additions and 3 deletions

View File

@ -130,11 +130,12 @@ module BSON
end end
def delete_if(&block) def delete_if(&block)
self.each do |k,v| keys.each do |key|
if yield k, v if yield key, self[key]
delete(k) delete(key)
end end
end end
self
end end
def reject(&block) def reject(&block)

View File

@ -212,6 +212,8 @@ class OrderedHashTest < Test::Unit::TestCase
assert @oh.keys.include?('z') assert @oh.keys.include?('z')
@oh.delete_if { |k,v| k == 'z' } @oh.delete_if { |k,v| k == 'z' }
assert !@oh.keys.include?('z') assert !@oh.keys.include?('z')
@oh.delete_if { |k, v| v > 0 }
assert @oh.keys.empty?
end end
def test_reject def test_reject