Module: Wolflow::DSL::SimpleDSL
- Defined in:
- lib/wolflow/dsl.rb
Instance Method Summary collapse
- #choose(*ids) ⇒ Object
- #connect(*ids) ⇒ Object
- #initialize ⇒ Object
- #join(id, *task_specs) ⇒ Object
- #on_complete(task) ⇒ Object
- #on_perform(&blk) ⇒ Object
Instance Method Details
#choose(*ids) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/wolflow/dsl.rb', line 62 def choose(*ids, **, &) return super unless ids.all?(String) && ids.size > 1 if_id, *else_ids = ids else_specs = else_ids.map { |else_id| Simple.new(id: else_id, workflow_spec: @workflow_spec) } super(*else_specs, id: if_id, &) end |
#connect(*ids) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/wolflow/dsl.rb', line 54 def connect(*ids, &) return super unless ids.all?(String) specs = ids.map { |id| Simple.new(id: id, workflow_spec: @workflow_spec) } super(*specs, &) end |
#initialize ⇒ Object
35 36 37 38 |
# File 'lib/wolflow/dsl.rb', line 35 def initialize(...) @on_complete_callbacks = [] super end |
#join(id, *task_specs) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/wolflow/dsl.rb', line 72 def join(id, *task_specs) synch = Synchronization.new(id: id, workflow_spec: @workflow_spec) synch.join(self, *task_specs) synch end |
#on_complete(task) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/wolflow/dsl.rb', line 46 def on_complete(task) @on_complete_callbacks.each do |blk| blk.call(task) end super end |
#on_perform(&blk) ⇒ Object
40 41 42 43 44 |
# File 'lib/wolflow/dsl.rb', line 40 def on_perform(&blk) @on_complete_callbacks << blk self end |