vendor/activesupport/lib/active_support/ordered_hash.rb in relevance-castronaut-0.5.4 vs vendor/activesupport/lib/active_support/ordered_hash.rb in relevance-castronaut-0.6.0
- old
+ new
@@ -10,10 +10,11 @@
pair.pop
pair << value
else
self << [key, value]
end
+ value
end
def [](key)
pair = assoc(key)
pair ? pair.last : nil
@@ -36,8 +37,22 @@
def to_hash
returning({}) do |hash|
each { |array| hash[array[0]] = array[1] }
end
end
+
+ def has_key?(k)
+ !assoc(k).nil?
+ end
+
+ alias_method :key?, :has_key?
+ alias_method :include?, :has_key?
+ alias_method :member?, :has_key?
+
+ def has_value?(v)
+ any? { |key, value| value == v }
+ end
+
+ alias_method :value?, :has_value?
end
end
end