-
Notifications
You must be signed in to change notification settings - Fork 0
flow object
The flow object can be accessed at any time in a Process, and it allows to access data and also to control the flow.
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
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
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
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
It will return true is no failure was raised.
It will return true if a process raised a flow failure and that failure was not cancelled by a handler.