Sha256: 8ec97fbdad576b52219ee6ff9dae5e475d13f52b9cda6b59caf96af894dad02b
Contents?: true
Size: 390 Bytes
Versions: 4
Compression:
Stored size: 390 Bytes
Contents
class Hash # Returns a new hash with only the given keys. def slice(*keep_keys) h = {} keep_keys.each do |key| h[key] = fetch(key) end h end # Replaces hash with a new hash having only the given keys. # This return the hash of keys removed. def slice!(*keep_keys) removed = except(*keep_keys) replace(slice(*keep_keys)) removed end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
facets-2.3.0 | lib/core/facets/hash/slice.rb |
facets-2.2.1 | lib/core/facets/hash/slice.rb |
facets-2.4.0 | lib/facets/hash/slice.rb |
facets-2.4.1 | lib/facets/hash/slice.rb |