Module: Fog::StringifyKeys

Defined in:
lib/fog/core/stringify_keys.rb

Class Method Summary collapse

Class Method Details

.stringify(original_hash) ⇒ Object

Returns a new hash with all keys converted to strings.



4
5
6
7
8
# File 'lib/fog/core/stringify_keys.rb', line 4

def self.stringify(original_hash)
  transform_hash(original_hash) do |hash, key, value|
    hash[key.to_s] = value
  end
end

.transform_hash(original, &block) ⇒ Object



11
12
13
14
15
16
# File 'lib/fog/core/stringify_keys.rb', line 11

def self.transform_hash(original, &block)
  original.reduce({}) do |result, (key, value)|
    block.call(result, key, value)
    result
  end
end