aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorSteve Purcell <steve@sanityinc.com>2008-06-03 14:15:33 -0500
committerJoshua Peek <josh@joshpeek.com>2008-06-03 14:15:33 -0500
commit7cfa6ec8a37b70ec302f09929df5160ac42971e7 (patch)
tree3ecd1a74837cba3c74513081ce35aff84fe8e74b /activesupport/lib
parentd54d90f2b590c763fe710482a9b993923fe03ec0 (diff)
downloadrails-7cfa6ec8a37b70ec302f09929df5160ac42971e7.tar.gz
rails-7cfa6ec8a37b70ec302f09929df5160ac42971e7.tar.bz2
rails-7cfa6ec8a37b70ec302f09929df5160ac42971e7.zip
Add more standard Hash methods to ActiveSupport::OrderedHash [#314 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/ordered_hash.rb14
1 files changed, 14 insertions, 0 deletions
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