lib/hashie/extensions/symbolize_keys.rb
# Convert all keys in hash to symbols.
#
# @param [Hash] hash
# @example
#   test = {'abc' => 'def'}
#   Hashie.symbolize_keys! test
#   test # => {:abc => 'def'}
Convert all keys in hash to symbols.
Convert all keys in hash to symbols .
def symbolize_keys!(hash)
          hash.extend(Hashie::Extensions::SymbolizeKeys) unless hash.respond_to?(:symbolize_keys!)
          hash.keys.each do |k| 
            symbolize_keys_recursively!(hash[k])
            hash[convert_key(k)] = hash.delete(k)
          end
          hash
        end
def symbolize_keys! ( hash ) hash . extend ( Hashie :: Extensions :: SymbolizeKeys ) unless hash . respond_to? ( :symbolize_keys! ) hash . keys . each do | k | symbolize_keys_recursively! ( hash [ k ] ) hash [ convert_key ( k ) ] = hash . delete ( k ) end hash end
Convert all keys in hash to symbols.
Convert all keys in hash to symbols .
# rubocop:disable Performance/HashEachMethods
hash
None
example
test = {'abc' => 'def'} Hashie.symbolize_keys.
test = { ' abc ' = > ' def ' } Hashie . symbolize_keys .