Class: Dry::AutoInject::Injector

Inherits:
BasicObject
Defined in:
lib/dry/auto_inject/injector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.



20
21
22
23
24
# File 'lib/dry/auto_inject/injector.rb', line 20

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) ⇒ Object (private)



32
# File 'lib/dry/auto_inject/injector.rb', line 32

def method_missing(name, ...) = builder.__send__(name)

Instance Attribute Details

#builderObject (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

#containerObject (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

#strategyObject (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



26
# File 'lib/dry/auto_inject/injector.rb', line 26

def [](*dependency_names) = strategy.new(container, *dependency_names)

#respond_to_missing?(name, _ = false) ⇒ Boolean

Returns:

  • (Boolean)


28
# File 'lib/dry/auto_inject/injector.rb', line 28

def respond_to_missing?(name, _ = false) = builder.respond_to?(name)