7669900126
- Introduced OrderedHash because db commands require that the command key be first. - Fixed BSON (de)serialization of object ids. - Simplified @coll.drop_indexes. - Renamed some method parameters to make their type more clear (for example, "collection" became "collection_name"). - Got the index_information test working.
27 lines
464 B
Ruby
27 lines
464 B
Ruby
class OrderedHash < Hash
|
|
|
|
attr_accessor :ordered_keys
|
|
|
|
def keys
|
|
@ordered_keys || []
|
|
end
|
|
|
|
def []=(key, value)
|
|
@ordered_keys ||= []
|
|
@ordered_keys << key unless @ordered_keys.include?(key)
|
|
super(key, value)
|
|
end
|
|
|
|
def each
|
|
@ordered_keys ||= []
|
|
@ordered_keys.each { |k| yield k, self[k] }
|
|
end
|
|
|
|
def merge(other)
|
|
@ordered_keys ||= []
|
|
@ordered_keys += other.keys # unordered if not an OrderedHash
|
|
super(other)
|
|
end
|
|
|
|
end
|