Sha256: a734f1b15b3e105817a0f9e8870c8972638a89bce742747b86e6cc85950bc82e
Contents?: true
Size: 571 Bytes
Versions: 11
Compression:
Stored size: 571 Bytes
Contents
## # Functions to convert hash keys to all symbols or all strings ## class Hash def deep_symbolize! hsh = nil hsh ||= self hsh.keys.each do |k| if k.is_a? String hsh[k.to_sym] = hsh[k] hsh.delete k end deep_symbolize! hsh[k.to_sym] if hsh[k.to_sym].is_a? Hash end hsh end def deep_stringify! hsh = nil hsh ||= self hsh.keys.each do |k| if k.is_a? Symbol hsh[k.to_s] = hsh[k] hsh.delete k end deep_stringify! hsh[k.to_s] if hsh[k.to_s].is_a? Hash end hsh end end
Version data entries
11 entries across 11 versions & 1 rubygems