Class: Dry::AutoInject::Injector
- Inherits:
- BasicObject
- Defined in:
- lib/dry/auto_inject/injector.rb
Instance Attribute Summary collapse
- #builder ⇒ Object readonly private
- #container ⇒ Object readonly private
- #strategy ⇒ Object readonly private
Instance Method Summary collapse
- #[](*dependency_names) ⇒ Object
-
#initialize(container, strategy, builder:) ⇒ Injector
constructor
private
A new instance of Injector.
- #respond_to?(name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(container, strategy, builder:) ⇒ Injector
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 Injector.
18 19 20 21 22 |
# File 'lib/dry/auto_inject/injector.rb', line 18 def initialize(container, strategy, builder:) @container = container @strategy = strategy @builder = builder end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (private)
34 35 36 |
# File 'lib/dry/auto_inject/injector.rb', line 34 def method_missing(name, *args, &block) builder.__send__(name) end |
Instance Attribute Details
#builder ⇒ 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.
15 16 17 |
# File 'lib/dry/auto_inject/injector.rb', line 15 def builder @builder end |
#container ⇒ 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.
9 10 11 |
# File 'lib/dry/auto_inject/injector.rb', line 9 def container @container end |
#strategy ⇒ 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.
12 13 14 |
# File 'lib/dry/auto_inject/injector.rb', line 12 def strategy @strategy end |
Instance Method Details
#[](*dependency_names) ⇒ Object
24 25 26 |
# File 'lib/dry/auto_inject/injector.rb', line 24 def [](*dependency_names) strategy.new(container, *dependency_names) end |
#respond_to?(name, include_private = false) ⇒ Boolean
28 29 30 |
# File 'lib/dry/auto_inject/injector.rb', line 28 def respond_to?(name, include_private = false) Injector.instance_methods.include?(name) || builder.respond_to?(name) end |