Class: Hash
Instance Method Summary collapse
-
#slice(*keys) ⇒ Object
File activesupport/lib/active_support/core_ext/hash/slice.rb, line 21.
Instance Method Details
#slice(*keys) ⇒ Object
File activesupport/lib/active_support/core_ext/hash/slice.rb, line 21
5 6 7 8 |
# File 'lib/core_ext/hash.rb', line 5 def slice(*keys) keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true) keys.each_with_object(self.class.new) { |k, hash| hash[k] = self[k] if key?(k) } end |