lib/hanami/utils/hash.rb
# Convert in-place all the keys to Symbol instances, nested hashes are converted too.
#
# @return [Hash] self
#
# @since 0.3.2
#
# @example
#   require 'hanami/utils/hash'
#
#   hash = Hanami::Utils::Hash.new a: 23, b: { c: ['x','y','z'] }
#   hash.stringify!
#
#   hash.keys    # => [:a, :b]
#   hash.inspect # => {"a"=>23, "b"=>{"c"=>["x", "y", "z"]}}
Convert in-place all the keys to Symbol instances, nested hashes are converted too.
Convert in - place all the keys to Symbol instances nested hashes are converted too .
def stringify!
        keys.each do |k|
          v = delete(k)
          v = self.class.new(v).stringify! if v.is_a?(::Hash) || v.is_a?(self.class)
          self[k.to_s] = v
        end
        self
      end
def stringify! keys . each do | k | v = delete ( k ) v = self . class . new ( v ) . stringify! if v . is_a? ( :: Hash ) || v . is_a? ( self . class ) self [ k . to_s ] = v end self end
Convert in-place all the keys to Symbol instances, nested hashes are converted too.
Convert in - place all the keys to Symbol instances nested hashes are converted too .
None
Hash
since
None
example
require 'hanami/utils/hash' hash = Hanami::Utils::Hash.new a: 23, b: { c: ['x','y','z'] } hash.stringify.
require ' hanami / utils / hash ' hash = Hanami :: Utils :: Hash . new a : 23 b : { c : [ ' x ' ' y ' ' z ' ] } hash . stringify .