From 7cfa6ec8a37b70ec302f09929df5160ac42971e7 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Tue, 3 Jun 2008 14:15:33 -0500 Subject: Add more standard Hash methods to ActiveSupport::OrderedHash [#314 state:resolved] Signed-off-by: Joshua Peek --- activesupport/lib/active_support/ordered_hash.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb index 6993621ef9..59ceaec696 100644 --- a/activesupport/lib/active_support/ordered_hash.rb +++ b/activesupport/lib/active_support/ordered_hash.rb @@ -38,6 +38,20 @@ module ActiveSupport 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 -- cgit v1.2.3