Sha256: 035566872e2554db04630ab79ea8e2d7440c461e6fa64889f805430949e2de90
Contents?: true
Size: 420 Bytes
Versions: 2
Compression:
Stored size: 420 Bytes
Contents
require "facets/hash/except" 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
facets-2.4.2 | lib/core/facets/hash/slice.rb |
facets-2.4.3 | lib/core/facets/hash/slice.rb |