Sha256: 5285545715724815f55673a118a6b3bf0996e85656384ae00c123b3624ebd6cc
Contents?: true
Size: 487 Bytes
Versions: 3
Compression:
Stored size: 487 Bytes
Contents
module Fog module StringifyKeys # Returns a new hash with all keys converted to strings. def self.stringify(original_hash) transform_hash(original_hash) do |hash, key, value| hash[key.to_s] = value end end # 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fog-core-2.6.0 | lib/fog/core/stringify_keys.rb |
fog-core-2.5.0 | lib/fog/core/stringify_keys.rb |
fog-core-2.4.0 | lib/fog/core/stringify_keys.rb |