Class: Dry::System::ProviderSourceRegistry Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/system/provider_source_registry.rb

Overview

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.

API:

  • private

Defined Under Namespace

Classes: Registration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProviderSourceRegistry

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.

API:

  • private



22
23
24
# File 'lib/dry/system/provider_source_registry.rb', line 22

def initialize
  @sources = {}
end

Instance Attribute Details

#sourcesObject (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.

API:

  • private



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.

API:

  • private



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}")].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.

API:

  • private



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: provider_options
  )
end

#register_from_block(name:, group:, 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.

API:

  • private



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:, &)
  register(
    name: name,
    group: group,
    source: Provider::Source.for(name: name, group: group, &),
    provider_options: 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.

API:

  • private



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