Sha256: 1190f0a4bba3f05bc393dbde9f31de99be7e7ef3c721cfc1bc32eb728b7549c3
Contents?: true
Size: 1.77 KB
Versions: 2
Compression:
Stored size: 1.77 KB
Contents
module Fog class << self attr_writer :providers end def self.providers @providers ||= {} end module Provider class << self 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 private def underscore_name(string) string.gsub("::", "/") .gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2') .gsub(/([a-z\d])([A-Z])/,'\1_\2') .tr("-", "_") .downcase end end def [](service_key) eval(@services_registry[service_key]).new end 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 def services @services_registry.keys end # 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". 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fog-core-2.6.0 | lib/fog/core/provider.rb |
fog-core-2.5.0 | lib/fog/core/provider.rb |