Class: Dry::AutoInject::Strategies::Constructor

Inherits:
Module
  • Object
show all
Defined in:
lib/dry/auto_inject/strategies/constructor.rb

Direct Known Subclasses

Args, Hash, Kwargs

Constant Summary collapse

ClassMethods =
::Class.new(::Module)
InstanceMethods =
::Class.new(::Module)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container, *dependency_names) ⇒ Constructor

Returns a new instance of Constructor.



15
16
17
18
19
20
21
# File 'lib/dry/auto_inject/strategies/constructor.rb', line 15

def initialize(container, *dependency_names)
  super()
  @container = container
  @dependency_map = DependencyMap.new(*dependency_names)
  @instance_mod = InstanceMethods.new
  @class_mod = ClassMethods.new
end

Instance Attribute Details

#class_modObject (readonly)

Returns the value of attribute class_mod.



13
14
15
# File 'lib/dry/auto_inject/strategies/constructor.rb', line 13

def class_mod
  @class_mod
end

#containerObject (readonly)

Returns the value of attribute container.



10
11
12
# File 'lib/dry/auto_inject/strategies/constructor.rb', line 10

def container
  @container
end

#dependency_mapObject (readonly)

Returns the value of attribute dependency_map.



11
12
13
# File 'lib/dry/auto_inject/strategies/constructor.rb', line 11

def dependency_map
  @dependency_map
end

#instance_modObject (readonly)

Returns the value of attribute instance_mod.



12
13
14
# File 'lib/dry/auto_inject/strategies/constructor.rb', line 12

def instance_mod
  @instance_mod
end

Instance Method Details

#included(klass) ⇒ 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.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/dry/auto_inject/strategies/constructor.rb', line 24

def included(klass)
  define_readers

  define_new
  define_initialize(klass)

  klass.send(:include, instance_mod)
  klass.extend(class_mod)

  super
end