Class: Dry::System::ProviderSourceRegistry Private

Inherits:
Object
  • Object
show all
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.

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.



11
12
13
# File 'lib/dry/system/provider_source_registry.rb', line 11

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.



9
10
11
# File 'lib/dry/system/provider_source_registry.rb', line 9

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.



15
16
17
18
19
# File 'lib/dry/system/provider_source_registry.rb', line 15

def load_sources(path)
  Dir[File.join(path, "**/#{RB_GLOB}")].sort.each do |file|
    require file
  end
end

#register(name:, group:, source:) ⇒ 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.



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

def register(name:, group:, source:)
  sources[key(name, group)] = source
end

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



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/dry/system/provider_source_registry.rb', line 25

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



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/dry/system/provider_source_registry.rb', line 37

def resolve(name:, group:)
  sources[key(name, group)].tap { |source|
    unless source
      raise ProviderSourceNotFoundError.new(
        name: name,
        group: group,
        keys: sources.keys
      )
    end
  }
end