Class: Dry::System::ProviderRegistry

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/dry/system/provider_registry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeProviderRegistry

Returns a new instance of ProviderRegistry.


8
9
10
# File 'lib/dry/system/provider_registry.rb', line 8

def initialize
  @items = []
end

Instance Attribute Details

#itemsObject (readonly)

Returns the value of attribute items.


6
7
8
# File 'lib/dry/system/provider_registry.rb', line 6

def items
  @items
end

Instance Method Details

#[](identifier) ⇒ Object


20
21
22
# File 'lib/dry/system/provider_registry.rb', line 20

def [](identifier)
  detect { |provider| provider.identifier == identifier }
end

#each(&block) ⇒ Object


12
13
14
# File 'lib/dry/system/provider_registry.rb', line 12

def each(&block)
  items.each(&block)
end

#register(identifier, options) ⇒ Object


16
17
18
# File 'lib/dry/system/provider_registry.rb', line 16

def register(identifier, options)
  items << Provider.new(identifier, options)
end