Module: Fog::ServicesMixin

Included in:
Account, Baremetal, Billing, CDN, Compute, DNS, Identity, Image, Metering, Monitoring, Network, Orchestration, Storage, Support, VPN, Volume
Defined in:
lib/fog/core/services_mixin.rb

Instance Method Summary collapse

Instance Method Details

#[](provider) ⇒ Object



3
4
5
# File 'lib/fog/core/services_mixin.rb', line 3

def [](provider)
  new(:provider => provider)
end

#new(attributes) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/core/services_mixin.rb', line 7

def new(attributes)
  attributes    = attributes.dup # Prevent delete from having side effects
  provider      = attributes.delete(:provider).to_s.downcase.to_sym
  provider_name = Fog.providers[provider]

  raise ArgumentError, "#{provider} is not a recognized provider" unless providers.include?(provider)

  require_service_provider_library(service_name.downcase, provider)
  spc = service_provider_constant(service_name, provider_name)
  spc.new(attributes)
rescue LoadError, NameError  # Only rescue errors in finding the libraries, allow connection errors through to the caller
  raise ArgumentError, "#{provider} has no #{service_name.downcase} service"
end

#providersObject



21
22
23
# File 'lib/fog/core/services_mixin.rb', line 21

def providers
  Fog.services[service_name.downcase.to_sym] || []
end