Module: Fog::Core::Utils

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

Class Method Summary collapse

Class Method Details

.prepare_service_settings(settings) ⇒ Hash

This helper prepares a Hash of settings for passing into Service.new.

The only special consideration is if :header key is passed in the contents are unchanged. This allows the headers to be passed through to requests to customise HTTP headers without them being broken by the #to_sym calls.

Parameters:

  • settings (Hash)

    The String based Hash to prepare

Options Hash (settings):

  • :headers (Hash)

    Passed to the underlying Connection unchanged

Returns:

  • (Hash)


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/core/utils.rb', line 14

def self.prepare_service_settings(settings)
  if settings.is_a? Hash
    copy = []
    settings.each do |key, value|
      obj = ![:headers].include?(key) ? prepare_service_settings(value) : value
      copy.push(key.to_sym, obj)
    end
    Hash[*copy]
  else
    settings
  end
end