Module: IIInteractor::Core

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

Instance Method Summary collapse

Instance Method Details

#callObject



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

def call
end

#call_allObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ii_interactor/core.rb', line 19

def call_all
  planned = coactors.map { |interactor| interactor.new(@context) } + [self]
  planned.each_with_index do |interactor, i|
    if i == planned.size - 1
      interactor.call_self
    else
      interactor.call_all
    end
    break if @context.stopped?
  end
end

#call_selfObject



31
32
33
34
35
# File 'lib/ii_interactor/core.rb', line 31

def call_self
  call.tap do
    @context._called << self
  end
end

#fail!(data = {}) ⇒ Object



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

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

#inform(*args) ⇒ Object



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

def inform(*args)
  @context._block.call(*([self] + args)) if @context._block
end

#initialize(context = {}, &block) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/ii_interactor/core.rb', line 11

def initialize(context = {}, &block)
  @context = if context.is_a?(IIInteractor::Context)
      context
    else
      IIInteractor::Context.new(context, &block)
    end
end

#rollbackObject



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

def rollback
end

#stop!(data = {}) ⇒ Object



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

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