Sha256: d89381e0e28112232040f2f9670d993f286aff852e7de697ab755079e1aa8500

Contents?: true

Size: 445 Bytes

Versions: 20

Compression:

Stored size: 445 Bytes

Contents

class Hash
  def depth
    1 + values.map { |v| v.is_a?(Hash) ? v.depth : 1 }.max
  end

  def deep_symbolize_keys
    self.each_with_object({}) do |(k, v), h|
      if v.is_a?(Array)
        v = v.map do |vv|
          if vv.is_a?(Hash)
            vv.deep_symbolize_keys
          else
            vv
          end
        end
      elsif v.is_a?(Hash)
        v = v.deep_symbolize_keys
      end

      h[k.to_s.to_sym] = v
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
rundock-1.2.1 lib/rundock/ext/hash.rb
rundock-1.2.0 lib/rundock/ext/hash.rb
rundock-1.1.7 lib/rundock/ext/hash.rb
rundock-1.1.6 lib/rundock/ext/hash.rb
rundock-1.1.5 lib/rundock/ext/hash.rb
rundock-1.1.4 lib/rundock/ext/hash.rb
rundock-1.1.3 lib/rundock/ext/hash.rb
rundock-1.1.2 lib/rundock/ext/hash.rb
rundock-1.1.1 lib/rundock/ext/hash.rb
rundock-1.1.0 lib/rundock/ext/hash.rb
rundock-1.0.8 lib/rundock/ext/hash.rb
rundock-1.0.7 lib/rundock/ext/hash.rb
rundock-1.0.6 lib/rundock/ext/hash.rb
rundock-1.0.5 lib/rundock/ext/hash.rb
rundock-1.0.4 lib/rundock/ext/hash.rb
rundock-1.0.2 lib/rundock/ext/hash.rb
rundock-1.0.1 lib/rundock/ext/hash.rb
rundock-1.0.0 lib/rundock/ext/hash.rb
rundock-0.5.8 lib/rundock/ext/hash.rb
rundock-0.5.7 lib/rundock/ext/hash.rb