Sha256: 9fd67419a22aa38d9bd508793bb6370630181a2b5a5f64792879d31214604529

Contents?: true

Size: 612 Bytes

Versions: 106

Compression:

Stored size: 612 Bytes

Contents

module Tins
  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

require 'tins/alias'

Version data entries

106 entries across 102 versions & 9 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/tins-0.13.2/lib/tins/hash_symbolize_keys_recursive.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/tins-0.13.2/lib/tins/hash_symbolize_keys_recursive.rb
tdiary-5.0.8 vendor/bundle/ruby/2.5.0/gems/tins-0.13.2/lib/tins/hash_symbolize_keys_recursive.rb
tdiary-5.0.8 vendor/bundle/gems/tins-0.13.2/lib/tins/hash_symbolize_keys_recursive.rb
tdiary-5.0.6 vendor/bundle/gems/tins-1.15.0/lib/tins/hash_symbolize_keys_recursive.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/tins-1.6.0/lib/tins/hash_symbolize_keys_recursive.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/tins-1.6.0/lib/tins/hash_symbolize_keys_recursive.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/tins-1.6.0/lib/tins/hash_symbolize_keys_recursive.rb
logstash-filter-cache-redis-0.1.0 vendor/bundle/jruby/1.9/gems/tins-1.6.0/lib/tins/hash_symbolize_keys_recursive.rb
tins-1.15.0 lib/tins/hash_symbolize_keys_recursive.rb
tdiary-5.0.5 vendor/bundle/gems/tins-1.13.2/lib/tins/hash_symbolize_keys_recursive.rb
tdiary-5.0.5 vendor/bundle/gems/tins-1.14.0/lib/tins/hash_symbolize_keys_recursive.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/tins-1.13.2/lib/tins/hash_symbolize_keys_recursive.rb
tins-1.14.0 lib/tins/hash_symbolize_keys_recursive.rb
tins-1.13.3 lib/tins/hash_symbolize_keys_recursive.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/tins-1.13.2/lib/tins/hash_symbolize_keys_recursive.rb
tdiary-5.0.4 vendor/bundle/gems/tins-1.13.2/lib/tins/hash_symbolize_keys_recursive.rb
tins-1.13.2 lib/tins/hash_symbolize_keys_recursive.rb
ivanvc-logstash-input-s3-3.1.1.4 vendor/local/gems/tins-1.13.0/lib/tins/hash_symbolize_keys_recursive.rb
ivanvc-logstash-input-s3-3.1.1.3 vendor/local/gems/tins-1.13.0/lib/tins/hash_symbolize_keys_recursive.rb