lib/packet/double_keyed_hash.rb in packet-0.1.4 vs lib/packet/double_keyed_hash.rb in packet-0.1.5
- old
+ new
@@ -13,11 +13,17 @@
def [] key
@internal_hash[key] || @internal_hash[@keys1[key]]
end
def delete(key)
- @keys1.delete(key)
- @internal_hash.delete(key)
+ t_key = @keys1[key]
+ if t_key
+ @keys1.delete(key)
+ @internal_hash.delete(t_key)
+ else
+ @keys1.delete_if { |key,value| value == key }
+ @internal_hash.delete(key)
+ end
end
def each
@internal_hash.each { |key,value| yield(key,value)}
end