lib/codecode/common/utils.rb
# BANG! Convert Hash string keys to symbol keys
#
# @param [Hash] hash
# @return [Hash] The resulting hash with symbolized keys
BANG. Convert Hash string keys to symbol keys
BANG . Convert Hash string keys to symbol keys
def symbolize_keys!(hash)
          new_hash = hash.inject({}){ |memo, (k, v)|
            memo[k.to_sym] = v
            if v.class.eql? ::Hash
              memo[k.to_sym] = symbolize_keys! v
            elsif v.class.eql? ::Array
              memo[k.to_sym] = symbolize_keys_of_hashs! v
            end
            memo
          }
          hash.replace new_hash
        end
def symbolize_keys! ( hash ) new_hash = hash . inject ( { } ) { | memo , ( k , v ) | memo [ k . to_sym ] = v if v . class . eql? :: Hash memo [ k . to_sym ] = symbolize_keys! v elsif v . class . eql? :: Array memo [ k . to_sym ] = symbolize_keys_of_hashs! v end memo } hash . replace new_hash end
BANG!
BANG!
The resulting hash with symbolized keys
The resulting hash with symbolized keys
Hash
hash
None