aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/hash/slice.rb
diff options
context:
space:
mode:
authorJosh Owens <joshua.owens@gmail.com>2008-07-16 19:31:37 -0500
committerJoshua Peek <josh@joshpeek.com>2008-07-16 19:31:37 -0500
commit396f9df8916b71f83aad8d56559cf55fc8501679 (patch)
tree05361067dd4c91f048493939fa8dbda442ec52e4 /activesupport/lib/active_support/core_ext/hash/slice.rb
parent7ae2105d57d3c08bebde44bd72093dd43c48d613 (diff)
downloadrails-396f9df8916b71f83aad8d56559cf55fc8501679.tar.gz
rails-396f9df8916b71f83aad8d56559cf55fc8501679.tar.bz2
rails-396f9df8916b71f83aad8d56559cf55fc8501679.zip
Hash#slice supports an array of keys [#613 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activesupport/lib/active_support/core_ext/hash/slice.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/slice.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/slice.rb b/activesupport/lib/active_support/core_ext/hash/slice.rb
index be4dec6e53..d3837d2e54 100644
--- a/activesupport/lib/active_support/core_ext/hash/slice.rb
+++ b/activesupport/lib/active_support/core_ext/hash/slice.rb
@@ -12,6 +12,7 @@ module ActiveSupport #:nodoc:
module Slice
# Returns a new hash with only the given keys.
def slice(*keys)
+ keys.flatten!
keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
hash = {}
keys.each { |k| hash[k] = self[k] if has_key?(k) }