From 396f9df8916b71f83aad8d56559cf55fc8501679 Mon Sep 17 00:00:00 2001 From: Josh Owens Date: Wed, 16 Jul 2008 19:31:37 -0500 Subject: Hash#slice supports an array of keys [#613 state:resolved] Signed-off-by: Joshua Peek --- activesupport/lib/active_support/core_ext/hash/slice.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'activesupport/lib/active_support') 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) } -- cgit v1.2.3