Sha256: 613078035cb2c9e9e0f07479e87386e46782f563aace3a1b1797ed7c279f7097
Contents?: true
Size: 482 Bytes
Versions: 13
Compression:
Stored size: 482 Bytes
Contents
module Fog module StringifyKeys # Returns a new hash with all keys converted to strings. def self.stringify(hash) transform_hash(hash) do |hash, key, value| hash[key.to_s] = value end end private # http://devblog.avdi.org/2009/11/20/hash-transforms-in-ruby/ def self.transform_hash(original, &block) original.reduce({}) do |result, (key, value)| block.call(result, key, value) result end end end end
Version data entries
13 entries across 13 versions & 2 rubygems