Class: Novel::Executor::ActivityFlow

Inherits:
Object
  • Object
show all
Defined in:
lib/novel/executor/activity_flow.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(container:, repository:) ⇒ ActivityFlow

Returns a new instance of ActivityFlow.



8
9
10
11
# File 'lib/novel/executor/activity_flow.rb', line 8

def initialize(container:, repository:)
  @container = container
  @repository = repository
end

Instance Attribute Details

#containerObject (readonly)

Returns the value of attribute container.



6
7
8
# File 'lib/novel/executor/activity_flow.rb', line 6

def container
  @container
end

#repositoryObject (readonly)

Returns the value of attribute repository.



6
7
8
# File 'lib/novel/executor/activity_flow.rb', line 6

def repository
  @repository
end

Instance Method Details

#call(context, state_machine, steps) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/novel/executor/activity_flow.rb', line 13

def call(context, state_machine, steps)
  steps.each_with_index do |step, index|
    result = execut_step(context, state_machine, step, steps[index + 1])

    return result if result.failure? || result.value![:status] == :waiting

    context = result.value![:context]
    result
  end

  Success(status: :finished, context: context)
end