Class: WFlow::ProcessWorker
- Inherits:
-
Object
- Object
- WFlow::ProcessWorker
- Defined in:
- lib/w_flow/process_worker.rb
Instance Method Summary collapse
- #finalize ⇒ Object
-
#initialize(process_class) ⇒ ProcessWorker
constructor
A new instance of ProcessWorker.
- #rollback ⇒ Object
- #run_as_child(flow) ⇒ Object
- #run_as_main(flow) ⇒ Object
Constructor Details
#initialize(process_class) ⇒ ProcessWorker
Returns a new instance of ProcessWorker.
4 5 6 |
# File 'lib/w_flow/process_worker.rb', line 4 def initialize(process_class) @process_class = process_class end |
Instance Method Details
#finalize ⇒ Object
31 32 33 34 35 |
# File 'lib/w_flow/process_worker.rb', line 31 def finalize @executed_nodes.reverse_each(&:finalize) @process.finalize if @setup_completed end |
#rollback ⇒ Object
37 38 39 40 41 |
# File 'lib/w_flow/process_worker.rb', line 37 def rollback @executed_nodes.reverse_each(&:rollback) @process.rollback if @perform_completed end |
#run_as_child(flow) ⇒ Object
25 26 27 28 29 |
# File 'lib/w_flow/process_worker.rb', line 25 def run_as_child(flow) setup(flow) run end |
#run_as_main(flow) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/w_flow/process_worker.rb', line 8 def run_as_main(flow) setup(flow) process_report = Supervisor.supervise { run } report = Supervisor.supervise do if process_report.failed? flow.set_failure_and_log(process_report.) rollback end finalize end raise InvalidOperation, INVALID_OPERATION unless report.success? end |