Class: Dry::AutoInject::Builder
- Inherits:
-
Object
- Object
- Dry::AutoInject::Builder
show all
- Defined in:
- lib/dry/auto_inject/builder.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(container, options = {}) ⇒ Builder
Returns a new instance of Builder.
15
16
17
18
|
# File 'lib/dry/auto_inject/builder.rb', line 15
def initialize(container, options = {})
@container = container
@strategies = options.fetch(:strategies) { Strategies }
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/dry/auto_inject/builder.rb', line 27
def method_missing(name, ...)
if strategies.key?(name)
Injector.new(container, strategies[name], builder: self)
else
super
end
end
|
Instance Attribute Details
#container ⇒ 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.
7
8
9
|
# File 'lib/dry/auto_inject/builder.rb', line 7
def container
@container
end
|
#strategies ⇒ 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.
10
11
12
|
# File 'lib/dry/auto_inject/builder.rb', line 10
def strategies
@strategies
end
|
Instance Method Details
#[](*dependency_names) ⇒ Object
21
|
# File 'lib/dry/auto_inject/builder.rb', line 21
def [](*dependency_names) = default[*dependency_names]
|
#respond_to_missing?(name, _ = false) ⇒ Boolean
23
|
# File 'lib/dry/auto_inject/builder.rb', line 23
def respond_to_missing?(name, _ = false) = strategies.key?(name)
|