Module: IIInteractor::Core

Extended by:
ActiveSupport::Concern
Includes:
Coactive::Initializer
Included in:
Base
Defined in:
lib/ii_interactor/core.rb

Instance Method Summary collapse

Instance Method Details

#callObject



43
44
# File 'lib/ii_interactor/core.rb', line 43

def call
end

#call_allObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ii_interactor/core.rb', line 16

def call_all
  planned = case IIInteractor.config.traversal
    when :preorder
      [self] + coactors
    when :postorder
      coactors + [self]
    when :inorder
      planned = coactors.in_groups(2, false)
      planned[0] + [self] + planned[1]
    end

  planned.each do |interactor|
    if interactor == self
      call_self
    else
      interactor.new(@context).call_all
    end
    break if @context.stopped?
  end
end

#call_selfObject



37
38
39
40
41
# File 'lib/ii_interactor/core.rb', line 37

def call_self
  call.tap do
    @context.called!(self)
  end
end

#fail!(data = {}) ⇒ Object



53
54
55
56
# File 'lib/ii_interactor/core.rb', line 53

def fail!(data = {})
  @context.fail!(data)
  raise UnprogressableError.new(@context)
end

#inform(*args) ⇒ Object



49
50
51
# File 'lib/ii_interactor/core.rb', line 49

def inform(*args)
  @context.call_block!(*([self] + args))
end

#initializeObject



12
13
14
# File 'lib/ii_interactor/core.rb', line 12

def initialize(*)
  super
end

#rollbackObject



46
47
# File 'lib/ii_interactor/core.rb', line 46

def rollback
end

#stop!(data = {}) ⇒ Object



58
59
60
# File 'lib/ii_interactor/core.rb', line 58

def stop!(data = {})
  @context.stop!(data)
end