Sha256: 9032eb0841dc05f881376269474af29dc3e8251c80fb42fac60e50cbc2312d3e

Contents?: true

Size: 323 Bytes

Versions: 15

Compression:

Stored size: 323 Bytes

Contents

class Hash
  def symbolize_keys
    self.each_with_object({}) do |(k, v), h|
      h[k.to_s.to_sym] = (v.is_a?(Hash) ? v.symbolize_keys : v)
      if v.is_a?(Array)
        h[k.to_s.to_sym] = v.each_with_object([]) do |h2, a|
          a << (h2.is_a?(Hash) ? h2.symbolize_keys : h2)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
dyna-0.2.3 lib/dyna/ext/hash-ext.rb
dyna-0.2.2 lib/dyna/ext/hash-ext.rb
dyna-0.2.1 lib/dyna/ext/hash-ext.rb
dyna-0.2.1.beta2 lib/dyna/ext/hash-ext.rb
dyna-0.2.1.beta1 lib/dyna/ext/hash-ext.rb
dyna-0.2.0 lib/dyna/ext/hash-ext.rb
dyna-0.1.9 lib/dyna/ext/hash-ext.rb
dyna-0.1.8 lib/dyna/ext/hash-ext.rb
dyna-0.1.7 lib/dyna/ext/hash-ext.rb
dyna-0.1.6 lib/dyna/ext/hash-ext.rb
dyna-0.1.5 lib/dyna/ext/hash-ext.rb
dyna-0.1.4 lib/dyna/ext/hash-ext.rb
dyna-0.1.3 lib/dyna/ext/hash-ext.rb
dyna-0.1.2 lib/dyna/ext/hash-ext.rb
dyna-0.1.1 lib/dyna/ext/hash-ext.rb