aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/hash/slice.rb
diff options
context:
space:
mode:
authoradam <adam@3scale.net>2008-09-23 12:08:24 +0200
committerMichael Koziarski <michael@koziarski.com>2008-09-23 14:04:20 +0200
commit2e75bd0808f4dcac328b690aaad176cbfe96773e (patch)
tree2ecf4896fe8ea72f89b4b7286a9746028b7f9dea /activesupport/lib/active_support/core_ext/hash/slice.rb
parentc452e49e763e3b7018f2cb550d318b2851703985 (diff)
downloadrails-2e75bd0808f4dcac328b690aaad176cbfe96773e.tar.gz
rails-2e75bd0808f4dcac328b690aaad176cbfe96773e.tar.bz2
rails-2e75bd0808f4dcac328b690aaad176cbfe96773e.zip
slice now returns indifferent hash if called on one
Signed-off-by: Michael Koziarski <michael@koziarski.com> [#1096 state:committed]
Diffstat (limited to 'activesupport/lib/active_support/core_ext/hash/slice.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/hash/slice.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/slice.rb b/activesupport/lib/active_support/core_ext/hash/slice.rb
index 3f14470f36..88df49a69f 100644
--- a/activesupport/lib/active_support/core_ext/hash/slice.rb
+++ b/activesupport/lib/active_support/core_ext/hash/slice.rb
@@ -18,7 +18,7 @@ module ActiveSupport #:nodoc:
# Returns a new hash with only the given keys.
def slice(*keys)
keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
- hash = {}
+ hash = self.class.new
keys.each { |k| hash[k] = self[k] if has_key?(k) }
hash
end