This commit is contained in:
Kyle Banker 2011-06-20 23:13:32 -04:00
parent 4f4e6ee833
commit 20d916bf98
1 changed files with 3 additions and 8 deletions

View File

@ -67,11 +67,10 @@ module BSON
end
def keys
@ordered_keys# || []
@ordered_keys.dup
end
def []=(key, value)
#@ordered_keys ||= []
unless has_key?(key)
@ordered_keys << key
end
@ -79,14 +78,12 @@ module BSON
end
def each
#@ordered_keys ||= []
@ordered_keys.each { |k| yield k, self[k] }
self
end
alias :each_pair :each
def to_a
#@ordered_keys ||= []
@ordered_keys.map { |k| [k, self[k]] }
end
@ -95,7 +92,7 @@ module BSON
end
def replace(other)
@ordered_keys = other.keys
@ordered_keys.replace(other.keys)
super
end
@ -106,7 +103,6 @@ module BSON
end
def merge!(other)
#@ordered_keys ||= []
@ordered_keys += other.keys # unordered if not an BSON::OrderedHash
@ordered_keys.uniq!
super(other)
@ -116,7 +112,6 @@ module BSON
def dup
result = OrderedHash.new
#@ordered_keys ||= []
@ordered_keys.each do |key|
result[key] = self[key]
end