Sha256: ea47d9d52cd0c063b30a6b737abd06268055f4fa41c3e173e2d535c63b4d3007

Contents?: true

Size: 398 Bytes

Versions: 15

Compression:

Stored size: 398 Bytes

Contents

class Hash
  def symbolize_keys(item=self)
    case item
    when Array
      item.map do |i|
        symbolize_keys(i)
      end
    when Hash
      Hash[
           item.map do |key, value|
             new_key = key.is_a?(String) ? key.to_sym : key
             new_value = symbolize_keys(value)
             [new_key, new_value]
           end
          ]
    else
      item
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
recognizer-0.1.5 lib/recognizer/patches/hash.rb
recognizer-0.1.4 lib/recognizer/patches/hash.rb
recognizer-0.1.3 lib/recognizer/patches/hash.rb
recognizer-0.1.2 lib/recognizer/patches/hash.rb
recognizer-0.1.1 lib/recognizer/patches/hash.rb
recognizer-0.1.0 lib/recognizer/patches/hash.rb
recognizer-0.0.10 lib/recognizer/patches/hash.rb
recognizer-0.0.9 lib/recognizer/patches/hash.rb
recognizer-0.0.8 lib/recognizer/patches/hash.rb
recognizer-0.0.7 lib/recognizer/patches/hash.rb
recognizer-0.0.6 lib/recognizer/patches/hash.rb
recognizer-0.0.4 lib/recognizer/patches/hash.rb
recognizer-0.0.3 lib/recognizer/patches/hash.rb
recognizer-0.0.2 lib/recognizer/patches/hash.rb
recognizer-0.0.1 lib/recognizer/patches/hash.rb