Sha256: 21f7e130a174c8f4e2937cdeff75912b51b629126508e20bcfc467bb3a500cd5
Contents?: true
Size: 528 Bytes
Versions: 1
Compression:
Stored size: 528 Bytes
Contents
class Hash 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 has_key?(k) } end def slice!(*keys) keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true) omit = slice(*self.keys - keys) hash = slice(*keys) replace(hash) omit end def extract!(*keys) keys.each_with_object(self.class.new) { |key, result| result[key] = delete(key) if has_key?(key) } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
happy_support-1.0.0 | lib/happy_support/core_ext/hash/slice.rb |