Sha256: 1a55d8b72101c7af72e089094eec723ec28792861f7d391927a4e756bb4138be
Contents?: true
Size: 485 Bytes
Versions: 34
Compression:
Stored size: 485 Bytes
Contents
# Collection of utility methods for the Hash object class HashUtil # Returns a hash with the keys converted to symbols def self.deep_symbolize_keys(hash) raise "Cannot symbolize keys for a nil object" if hash.nil? hash.keys.each do |key| value = hash[key] hash.delete(key) hash[key.to_sym] = value if hash[key.to_sym].instance_of? Hash hash[key.to_sym] = HashUtil.deep_symbolize_keys(hash[key.to_sym]) end end hash end end
Version data entries
34 entries across 34 versions & 1 rubygems