module Fog::StringifyKeys

Public Class Methods

stringify(original_hash) click to toggle source

Returns a new hash with all keys converted to strings.

# 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

Private Class Methods

transform_hash(original, &block) click to toggle source

devblog.avdi.org/2009/11/20/hash-transforms-in-ruby/

# File lib/fog/core/stringify_keys.rb, line 13
def self.transform_hash(original, &block)
  original.reduce({}) do |result, (key, value)|
    block.call(result, key, value)
    result
  end
end