Class: ConfigurationService::ProviderRegistry
- Inherits:
-
Object
- Object
- ConfigurationService::ProviderRegistry
- Includes:
- Singleton
- Defined in:
- lib/configuration_service/provider_registry.rb
Overview
A singleton registry of configuration service providers
Class Method Summary collapse
-
.instance ⇒ ConfigurationService::ProviderRegistry
The singleton registry instance.
Instance Method Summary collapse
-
#lookup(identifier) ⇒ Class?
Look up a configuration service provider.
-
#register(identifier, provider) ⇒ Object
Register a configuration service provider.
Class Method Details
.instance ⇒ ConfigurationService::ProviderRegistry
The singleton registry instance
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/configuration_service/provider_registry.rb', line 15 class ProviderRegistry include Singleton ## # Register a configuration service provider # # @param [String] identifier # unique identifier for the configuration service provider # @param [Class] provider # the configuration service provider class # def register(identifier, provider) @providers[identifier] = provider end ## # Look up a configuration service provider # # @param [String] identifier # the unique identifier for the configuration service provider. # The provider must already have been registered with {#register}. # # @return [Class] the configuration service provider class # @return [nil] if no provider has been registered with the given +identifier+ # def lookup(identifier) @providers[identifier] end # @private def initialize @providers = {} end end |
Instance Method Details
#lookup(identifier) ⇒ Class?
Look up a configuration service provider
41 42 43 |
# File 'lib/configuration_service/provider_registry.rb', line 41 def lookup(identifier) @providers[identifier] end |
#register(identifier, provider) ⇒ Object
Register a configuration service provider
27 28 29 |
# File 'lib/configuration_service/provider_registry.rb', line 27 def register(identifier, provider) @providers[identifier] = provider end |