Module: Fog::Provider
- Defined in:
- lib/fog/core/provider.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](service_key) ⇒ Object
- #service(new_service, constant_string) ⇒ Object
-
#service_klass(constant_string) ⇒ Object
Returns service constant path, with provider, as string.
- #services ⇒ Object
Class Method Details
.extended(base) ⇒ Object
11 12 13 14 |
# File 'lib/fog/core/provider.rb', line 11 def self.extended(base) provider = base.to_s.split("::").last Fog.providers[provider.downcase.to_sym] = provider end |
Instance Method Details
#[](service_key) ⇒ Object
16 17 18 |
# File 'lib/fog/core/provider.rb', line 16 def [](service_key) eval(@services_registry[service_key]).new end |
#service(new_service, constant_string) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/fog/core/provider.rb', line 20 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”.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fog/core/provider.rb', line 34 def service_klass(constant_string) eval([to_s, constant_string].join("::")) [to_s, constant_string].join("::") rescue NameError 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 |
#services ⇒ Object
27 28 29 |
# File 'lib/fog/core/provider.rb', line 27 def services @services_registry.keys end |