Class: Dry::System::ProviderSourceRegistry Private
- Inherits:
-
Object
- Object
- Dry::System::ProviderSourceRegistry
- Defined in:
- lib/dry/system/provider_source_registry.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: Registration
Instance Attribute Summary collapse
- #sources ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize ⇒ ProviderSourceRegistry
constructor
private
A new instance of ProviderSourceRegistry.
- #load_sources(path) ⇒ Object private
- #register(name:, group:, source:, provider_options:) ⇒ Object private
- #register_from_block(name:, group:, provider_options:, &block) ⇒ Object private
- #resolve(name:, group:) ⇒ Object private
Constructor Details
#initialize ⇒ ProviderSourceRegistry
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ProviderSourceRegistry.
22 23 24 |
# File 'lib/dry/system/provider_source_registry.rb', line 22 def initialize @sources = {} end |
Instance Attribute Details
#sources ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/dry/system/provider_source_registry.rb', line 20 def sources @sources end |
Instance Method Details
#load_sources(path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 29 30 |
# File 'lib/dry/system/provider_source_registry.rb', line 26 def load_sources(path) Dir[File.join(path, "**/#{RB_GLOB}")].sort.each do |file| require file end end |
#register(name:, group:, source:, provider_options:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 36 37 |
# File 'lib/dry/system/provider_source_registry.rb', line 32 def register(name:, group:, source:, provider_options:) sources[key(name, group)] = Registration.new( source: source, provider_options: ) end |
#register_from_block(name:, group:, provider_options:, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 42 43 44 45 46 |
# File 'lib/dry/system/provider_source_registry.rb', line 39 def register_from_block(name:, group:, provider_options:, &block) register( name: name, group: group, source: Provider::Source.for(name: name, group: group, &block), provider_options: ) end |
#resolve(name:, group:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/dry/system/provider_source_registry.rb', line 48 def resolve(name:, group:) sources[key(name, group)].tap { |source| unless source raise ProviderSourceNotFoundError.new( name: name, group: group, keys: sources.keys ) end } end |