Module: Util

Included in:
RedisConnector
Defined in:
lib/redis_connector/util.rb

Instance Method Summary collapse

Instance Method Details

#stringify_keys(hash) ⇒ Hash

Stringifies the keys of the specified hash.

Parameters:

  • hash (Hash)

    a hash for which keys should be stringified

Returns:

  • (Hash)

    a new hash with stringified keys



14
15
16
# File 'lib/redis_connector/util.rb', line 14

def stringify_keys(hash)
  Hash[hash.map { |k, v| [k.to_s, v] }]
end

#symbolize_keys(hash) ⇒ Hash

Symbolizes the keys of the specified hash.

Parameters:

  • hash (Hash)

    a hash for which keys should be symbolized

Returns:

  • (Hash)

    a new hash with symbolized keys



6
7
8
# File 'lib/redis_connector/util.rb', line 6

def symbolize_keys(hash)
  Hash[hash.map { |k, v| [k.to_sym, v] }]
end