Sha256: a534935778cadaa57e4569691cfaf6328281862936ebd30f253070f3f9656c92
Contents?: true
Size: 819 Bytes
Versions: 4
Compression:
Stored size: 819 Bytes
Contents
class Hash unless method_defined?(:reverse_merge!) def reverse_merge!(other = {}) other.each{|k,v| self[k] ||= v} self end end unless method_defined?(:slice!) def slice!(*keys) keys = keys.flatten out = {} keys.each{|k| out[k] = self[k]} replace out self end def slice(*keys) out = dup out.slice!(*keys) end end unless method_defined?(:symbolize_keys) def symbolize_keys out = dup out.symbolize_keys! end end unless method_defined?(:symbolize_keys!) def symbolize_keys! symbolizable_keys = [] keys.each{|k| symbolizable_keys << k if k.respond_to?(:to_sym) && !k.is_a?(Symbol)} symbolizable_keys.each do |k| self[k.to_sym] = delete(k) end self end end end
Version data entries
4 entries across 4 versions & 1 rubygems