RUBY-359 Fix for OrderedHash on 1.8.7
This commit is contained in:
parent
6f57665631
commit
24b9653366
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue