we still need to define ==, even in 1.9
This commit is contained in:
parent
6171b480d7
commit
ac4dde5d76
|
@ -20,6 +20,12 @@
|
|||
# Hash already keeps its keys ordered by order of insertion.
|
||||
class OrderedHash < Hash
|
||||
|
||||
def ==(other)
|
||||
!other.nil? &&
|
||||
keys == other.keys &&
|
||||
values == other.values
|
||||
end
|
||||
|
||||
# We only need the body of this class if the RUBY_VERSION is before 1.9
|
||||
if RUBY_VERSION < '1.9'
|
||||
|
||||
|
@ -35,12 +41,6 @@ class OrderedHash < Hash
|
|||
super(key, value)
|
||||
end
|
||||
|
||||
def ==(other)
|
||||
!other.nil? &&
|
||||
keys == other.keys &&
|
||||
values == other.values
|
||||
end
|
||||
|
||||
def each
|
||||
@ordered_keys ||= []
|
||||
@ordered_keys.each { |k| yield k, self[k] }
|
||||
|
|
Loading…
Reference in New Issue