Sha256: 656c7f938f12e6d3f846bf6974e84bf56196384cbf7e510cf88f446cd85a425d
Contents?: true
Size: 619 Bytes
Versions: 1
Compression:
Stored size: 619 Bytes
Contents
class Hash def slice(*keys) keys.each_with_object(self.class.new) { |k, hash| hash[k] = self[k] if has_key?(k) } end def extract(*keys) self.each_with_object(self.class.new) { |(k, v), hash| hash[k] = v unless keys.include?(k) } end def symbolize_keys self.each_with_object(self.class.new) { |(k, v), hash| v = v.symbolize_keys if v.class.name == self.class.name hash[:"#{k}"] = v } end def stringify_keys self.each_with_object(self.class.new) { |(k, v), hash| v = v.stringify_keys if v.is_a?(self.class) hash["#{k}"] = v } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trellohub-0.1.0 | lib/trellohub/core_ext/hash.rb |