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



36
37
38
# File 'lib/dry/auto_inject/injector.rb', line 36

def method_missing(name, *_args)
  builder.__send__(name)
end

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
27
28
# File 'lib/dry/auto_inject/injector.rb', line 26

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

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

Returns:

  • (Boolean)


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

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