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

Version Path
fog-core-1.38.0 lib/fog/core/stringify_keys.rb
fog-core-1.37.0 lib/fog/core/stringify_keys.rb
fog-core-1.36.0 lib/fog/core/stringify_keys.rb
fog-core-1.35.0 lib/fog/core/stringify_keys.rb
fog-core-1.34.0 lib/fog/core/stringify_keys.rb
fog-core-1.33.0 lib/fog/core/stringify_keys.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-core-1.32.1/lib/fog/core/stringify_keys.rb
fog-core-1.32.1 lib/fog/core/stringify_keys.rb
fog-core-1.32.0 lib/fog/core/stringify_keys.rb
fog-core-1.31.1 lib/fog/core/stringify_keys.rb
fog-core-1.31.0 lib/fog/core/stringify_keys.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-core-1.30.0/lib/fog/core/stringify_keys.rb
fog-core-1.30.0 lib/fog/core/stringify_keys.rb