Sha256: 036b950aa07fe3fc50e13a6b0f58a8faf4ea6cb54d0fe9413a0a34266594e222
Contents?: true
Size: 653 Bytes
Versions: 2
Compression:
Stored size: 653 Bytes
Contents
module Cradlepoint module HashHelpers # From # http://devblog.avdi.org/2009/07/14/recursively-symbolize-keys/ def symbolize_keys(hash) if hash.is_a?(Array) hash.map { |h| symbolize_keys(h) } else hash.inject({}) { |result, (key, value)| new_key = case key when String then key.to_sym else key end new_value = case value when Hash then symbolize_keys(value) else value end result[new_key] = new_value result } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cradlepoint-0.1.2 | lib/cradlepoint/hash_helpers.rb |
cradlepoint-0.1.1 | lib/cradlepoint/hash_helpers.rb |