Module: ConfigurationService::Factory
- Defined in:
- lib/configuration_service/factory.rb,
lib/configuration_service/factory/context.rb,
lib/configuration_service/factory/yaml_file_context.rb,
lib/configuration_service/factory/environment_context.rb,
lib/configuration_service/factory/context/symbolic_access_wrapper.rb,
lib/configuration_service/factory/environment_context_backward_compatibility.rb
Overview
A factory for creating a configuration service client
Defined Under Namespace
Modules: EnvironmentContextBackwardCompatibility Classes: Context, EnvironmentContext, YamlFileContext
Class Method Summary collapse
-
.create_admin_client(context = EnvironmentContext.new) ⇒ Object
deprecated
Deprecated.
use create_client()
-
.create_client(context = EnvironmentContext.new) ⇒ ConfigurationService::Client
Create a configuration service client.
Class Method Details
.create_admin_client(context = EnvironmentContext.new) ⇒ Object
use create_client()
@ see create_client()
82 83 84 |
# File 'lib/configuration_service/factory.rb', line 82 def self.create_admin_client(context = EnvironmentContext.new) create_client(context) end |
.create_client(context = EnvironmentContext.new) ⇒ ConfigurationService::Client
Create a configuration service client
When the context
is a Hash, it is wrapped in a Context, which does not scrub sources after the configuration service client is created. For this reason, the process ENV
should never be given as the context
; rather give no context
, so that the default EnvironmentContext will be used to safely scrub the process ENV
and (on JRuby) system properties after the configuration service client is created.
If the context does not provide an identifier
property, the instance methods on the client object will require an identifier
argument.
68 69 70 71 72 73 74 75 76 |
# File 'lib/configuration_service/factory.rb', line 68 def self.create_client(context = EnvironmentContext.new) context = Context.new(context) if context.is_a?(Hash) decorators = get_decorators(context.decorators) provider = decorators.any? ? decorate(decorators << create_provider(context)) : create_provider(context) identifier = context.identifier? ? context.identifier : nil ConfigurationService::Client.new(credentials: context.token, provider: provider, identifier: identifier) ensure context.scrub! end |