slice now returns indifferent hash if called on one
Signed-off-by: Michael Koziarski <michael@koziarski.com> [#1096 state:committed]
This commit is contained in:
parent
c452e49e76
commit
2e75bd0808
@ -18,7 +18,7 @@ module Slice
|
|||||||
# Returns a new hash with only the given keys.
|
# Returns a new hash with only the given keys.
|
||||||
def slice(*keys)
|
def slice(*keys)
|
||||||
keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
|
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) }
|
keys.each { |k| hash[k] = self[k] if has_key?(k) }
|
||||||
hash
|
hash
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user