Sha256: a6b5639ad3b046c290f228c0298bf5090d302143f383536cefeb6dca5065a284
Contents?: true
Size: 648 Bytes
Versions: 13
Compression:
Stored size: 648 Bytes
Contents
class Hash def remove_nils clear_nils = Proc.new { |k, v| v.kind_of?(Hash) ? (v.delete_if(&clear_nils); nil) : v.nil? }; self.delete_if(&clear_nils) end def convert_keys_to_strings Hash.convert_keys_to_strings(self) self end def self.convert_keys_to_strings(hash) if hash.kind_of? Hash hash.keys.each do |k| v = hash[k] if k.kind_of? Symbol hash[k.to_s] = hash[k] hash.delete(k) end Hash.convert_keys_to_strings(v) end elsif hash.kind_of? Array hash.each{|val| Hash.convert_keys_to_strings(val)} end end end
Version data entries
13 entries across 13 versions & 1 rubygems