Sha256: 3ddcdb999fc4b9bae357843eb4099e11b3df77ac8608509fdb7f36b69cb08c80
Contents?: true
Size: 600 Bytes
Versions: 1
Compression:
Stored size: 600 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) hash.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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cistern-1.0.1.pre4 | lib/cistern/hash.rb |