Module: Fog::Provider

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



12
13
14
15
16
# File 'lib/fog/core/provider.rb', line 12

def extended(base)
  provider = base.to_s.split("::").last
  Fog.providers[provider.downcase.to_sym] = provider
  Fog.providers[underscore_name(provider).to_sym] = provider
end

Instance Method Details

#[](service_key) ⇒ Object



29
30
31
# File 'lib/fog/core/provider.rb', line 29

def [](service_key)
  eval(@services_registry[service_key]).new
end

#service(new_service, constant_string) ⇒ Object



33
34
35
36
37
38
# File 'lib/fog/core/provider.rb', line 33

def service(new_service, constant_string)
  Fog.services[new_service] ||= []
  Fog.services[new_service] |= [to_s.split("::").last.downcase.to_sym]
  @services_registry ||= {}
  @services_registry[new_service] = service_klass(constant_string)
end

#service_klass(constant_string) ⇒ Object

Returns service constant path, with provider, as string. If “provider::service” is defined (the preferred format) then it returns that string, otherwise it returns the deprecated string “service::provider”.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fog/core/provider.rb', line 47

def service_klass(constant_string)
  if const_defined?([to_s, constant_string].join("::"))
    [to_s, constant_string].join("::")
  else
    provider = to_s.split("::").last
    Fog::Logger.deprecation("Unable to load #{[to_s, constant_string].join('::')}")
    Fog::Logger.deprecation(
      format(
        Fog::ServicesMixin::E_SERVICE_PROVIDER_CONSTANT,
        service: constant_string,
        provider: provider
      )
    )
    ["Fog", constant_string, provider].join("::")
  end
end

#servicesObject



40
41
42
# File 'lib/fog/core/provider.rb', line 40

def services
  @services_registry.keys
end