Sha256: e7213b91a67b01bf725637ce8a88288a290219ce1a25aaaf144bc0501ca2b6b4
Contents?: true
Size: 603 Bytes
Versions: 5
Compression:
Stored size: 603 Bytes
Contents
class Cistern::Hash def self.slice(hash, *keys) {}.tap do |sliced| keys.each { |k| sliced[k] = hash[k] if hash.key?(k) } end end def self.except(hash, *keys) Cistern::Hash.except!(hash.dup, *keys) end # Replaces the hash without the given keys. def self.except!(hash, *keys) keys.each { |key| hash.delete(key) } hash end def self.stringify_keys(object) case object when Hash object.inject({}) { |r, (k, v)| r.merge(k.to_s => stringify_keys(v)) } when Array object.map { |v| stringify_keys(v) } else object end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
cistern-2.3.0 | lib/cistern/hash.rb |
cistern-2.2.7 | lib/cistern/hash.rb |
cistern-2.2.6 | lib/cistern/hash.rb |
cistern-2.2.5 | lib/cistern/hash.rb |
cistern-2.2.4 | lib/cistern/hash.rb |