Sha256: 6c11f29d7c3c3db259044f56b823a465f634d85a57541e29eeb75391ee524f3d
Contents?: true
Size: 591 Bytes
Versions: 7
Compression:
Stored size: 591 Bytes
Contents
module Spruz module HashSymbolizeKeysRecursive def symbolize_keys_recursive inject(self.class.new) do |h,(k, v)| k = k.to_s k.empty? and next case v when Hash h[k.to_sym] = v.symbolize_keys_recursive when Array h[k.to_sym] = a = v.dup v.each_with_index do |x, i| Hash === x and a[i] = x.symbolize_keys_recursive end else h[k.to_sym] = v end h end end def symbolize_keys_recursive! replace symbolize_keys_recursive end end end
Version data entries
7 entries across 7 versions & 1 rubygems