Skip to content
Jun Hanamaki edited this page Jun 7, 2015 · 1 revision

The flow object can be accessed at any time in a Process, and it allows to access data and also to control the flow.

flow attributes and methods

data

It's how a Process can access its inputs and also where it should write its output values.

For a Process that is invoked with the following hash:

TestProcess.run(test_text: 'hello')

The flow will make hash available under object data:

class TestProcess
  include WFlow::Process

  def perform
    puts flow.data.test_text
  end
end

stop!

When invoked it will immediately stop the execution of the current Process, and unless canceled by a handler it will also stop the main Process and finalize all Processes:

class TestProcess
  include WFLow::Process

  def perform
    flow.stop!
  end
end

skip!

Should be used inside setup, and when invoked it will immediately exit the execution of the current Process, and not execute any of its execute chains:

class TestProcess
  include WFlow::Process

  def setup
    flow.skip!
  end

  # neither Processes in execute, not methods perform, finalize or rollback will be called, since this Process
  # was skipped
  execute AnotherProcess, YetAnotherProcess

  def perform
  end
end

failure!

When invoked it will immediately stop the execution of the current Process, and unless canceled by a handler it will also stop the main Process, mark flow as failure, and rollback and finalize all Processes:

class TestProcess
  include WFlow::Process

  def perform
    # you can also invoke without arguments
    flow.failure!('some error message')
  end
end

success?

It will return true is no failure was raised.

failure?

It will return true if a process raised a flow failure and that failure was not cancelled by a handler.

Clone this wiki locally