Sha256: 6a0793998879093427640c5756f05d73d382626bbfa9b275183e4e4a4f6e0710
Contents?: true
Size: 733 Bytes
Versions: 30
Compression:
Stored size: 733 Bytes
Contents
class Hash def symbolize Hash.symbolize_hash(self) end def self.symbolize_hash(obj) case obj when Array obj.inject([]){|res, val| res << case val when Hash, Array symbolize_hash(val) when String val.to_sym else val end res } when Hash obj.inject({}){|res, (key, val)| nkey = case key when String key.to_sym else key end nval = case val when Hash, Array symbolize_hash(val) when String val.to_sym else val end res[nkey] = nval res } else obj end end end
Version data entries
30 entries across 30 versions & 5 rubygems