Class: Trailblazer::Operation::AutoInject::InjectStrategy

Inherits:
Module
  • Object
show all
Defined in:
lib/trailblazer/operation/auto_inject.rb

Constant Summary collapse

ClassMethods =
Class.new(Module)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Module

included

Constructor Details

#initialize(container, *dependency_names) ⇒ InjectStrategy

Returns a new instance of InjectStrategy.



14
15
16
17
18
# File 'lib/trailblazer/operation/auto_inject.rb', line 14

def initialize(container, *dependency_names)
  @container = container
  @dependency_map = Dry::AutoInject::DependencyMap.new(*dependency_names)
  @class_mod = ClassMethods.new
end

Instance Attribute Details

#class_modObject (readonly)

Returns the value of attribute class_mod.



12
13
14
# File 'lib/trailblazer/operation/auto_inject.rb', line 12

def class_mod
  @class_mod
end

#containerObject (readonly)

Returns the value of attribute container.



10
11
12
# File 'lib/trailblazer/operation/auto_inject.rb', line 10

def container
  @container
end

#dependency_mapObject (readonly)

Returns the value of attribute dependency_map.



11
12
13
# File 'lib/trailblazer/operation/auto_inject.rb', line 11

def dependency_map
  @dependency_map
end

Instance Method Details

#included(klass) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/trailblazer/operation/auto_inject.rb', line 20

def included(klass)
  define_call

  klass.singleton_class.prepend @class_mod

  super
end