Sha256: 9199a353f65cc71bee322f4fe5699b066d905adf07bb4ac519be5c3a3f5e2f36
Contents?: true
Size: 772 Bytes
Versions: 3
Compression:
Stored size: 772 Bytes
Contents
# encoding: utf-8 module ServiceObjects # Utilitites for ServiceObjects module module Utils # Constructor of hash with keys, symbolized at any level # # @example # NormalHash.from { "foo" => "bar", "bar" => { "baz", "bar" => "baz" } } # # => { foo: "baz", bar: { "baz", bar: "baz" } } # # @api private module NormalHash # Recursively symbolizes keys of hash at any level # # @param [Hash] hash # # @return [Hash] def self.from(hash) return {} unless hash.is_a? Hash hash.inject({}) do |out, (key, val)| out.merge(key.to_sym => (val.is_a?(Hash) ? from(val) : val)) end end end # class NormalHash end # module Utils end # module ServiceObjects
Version data entries
3 entries across 3 versions & 1 rubygems