Sha256: 3e10f8d0bbf7bb58c2eb5f255f8ef9774c882f4585fb0a55bb03b5ad95334217
Contents?: true
Size: 615 Bytes
Versions: 11
Compression:
Stored size: 615 Bytes
Contents
Hash.class_eval do #take keys of hash and transform those to a symbols def self.symbolize_keys(item) if item.class == Hash item.to_options! item.each do |key, value| self.symbolize_keys(value) end elsif item.class == Array item.each do |array_val| self.symbolize_keys(array_val) end end item end #merge hash and overwrite key only if it is nil def apply_if(hash) self.merge(hash){|key, v1, v2| v1.nil? ? v2 : v1} end def apply_if!(hash) self.merge!(hash){|key, v1, v2| v1.nil? ? v2 : v1} end end
Version data entries
11 entries across 11 versions & 1 rubygems