Sha256: 109bbe638bff05d21f02d8ead8a11b8b72888e00e771a7d86e6b26a824ab69fc
Contents?: true
Size: 342 Bytes
Versions: 12
Compression:
Stored size: 342 Bytes
Contents
class Hash # Destructively convert all keys which respond_to?(:to_sym) to symbols. Works recursively if given nested hashes. def symbolize_keys! each do |k,v| sym = k.respond_to?(:to_sym) ? k.to_sym : k self[sym] = Hash === v ? v.symbolize_keys! : v delete(k) unless k == sym end self end end
Version data entries
12 entries across 12 versions & 2 rubygems