Class: Ruote::Exp::AddBranchesExpression
- Inherits:
-
FlowExpression
- Object
- FlowExpression
- Ruote::Exp::AddBranchesExpression
- Includes:
- IteratorMixin
- Defined in:
- lib/ruote/exp/fe_add_branches.rb
Overview
The ‘add_branches’/‘add_branch’ expression can be used to add branches to a concurrent-iterator while it is running.
concurrent_iterator :on => 'a, b, c' do
sequence do
participant :ref => 'worker_${v:i}'
add_branches 'd, e', :if => '${v:/not_sufficient}'
end
end
In this example, if the process level variable ‘not_sufficient’ is set to true, workers d and e will be added to the iterated elements.
‘add_branches’ understand comma-separated list of values or direcltly array of values, like the concurrent_iterator does. The :sep or :separator attribute can be used for custom separators :
add_branches 'd|e|f', :sep => '|'
:ref
By default, add_branches looks up the first parent expression that is concurrent_iterator. This is all well, but what when you have nested concurrent_iterator and want to hit the enclosing one from inside the enclosed one ? Or when you want to add branches from somewhere else in the process instance, outside of the concurrent_iterator ?
concurrence do
concurrent_iterator :on => 'a, b, c', :tag => 'main' do
subprocess :ref => 'perform_work'
end
sequence do
subprocess :ref => 'supervise_work'
add_branches 'd, e', :ref => 'main', :if => '${f:more_cowbell}'
rewind :if => '${f:more_cowbell}'
end
end
The add_branches expression refers to the ‘main’ concurrent_iterator via the :ref => ‘main’ attribute.
missing concurrent_iterator
If :ref points to nothing or add_branch has no :ref and is not placed inside of a concurrent_iterator, the expression will silently have no effect.
Constant Summary
Constants inherited from FlowExpression
FlowExpression::COMMON_ATT_KEYS
Instance Attribute Summary
Attributes inherited from FlowExpression
Instance Method Summary collapse
Methods inherited from FlowExpression
#ancestor?, #att, #attribute, #attribute_text, #attributes, #cancel, #compile_atts, #compile_variables, do_action, #do_apply, #do_cancel, #do_fail, #do_pause, #do_persist, #do_reply, #do_resume, #do_unpersist, #expand_atts, #fei, fetch, from_h, #handle_on_error, #has_attribute, #initial_persist, #initialize, #iterative_var_lookup, #launch_sub, #lookup_on_error, #lookup_val, #lookup_val_prefix, #lookup_variable, #name, names, #parent, #parent_id, #persist_or_raise, #reply_to_parent, #set_variable, #to_h, #tree, #tree_children, #try_persist, #try_unpersist, #unpersist_or_raise, #unset_variable, #update_tree, #variables
Methods included from WithMeta
Methods included from WithH
Constructor Details
This class inherits a constructor from Ruote::Exp::FlowExpression
Instance Method Details
#apply ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ruote/exp/fe_add_branches.rb', line 88 def apply list = split_list(lookup_val_prefix('on') || attribute_text) it_fei = find_concurrent_iterator if list && it_fei wi = Ruote.fulldup(h.applied_workitem) wi['fields'][ConcurrentIteratorExpression::ADD_BRANCHES_FIELD] = list @context.storage.put_msg('reply', 'fei' => it_fei, 'workitem' => wi) end reply_to_parent(h.applied_workitem) end |
#reply(workitem) ⇒ Object
104 105 106 107 |
# File 'lib/ruote/exp/fe_add_branches.rb', line 104 def reply(workitem) # never called end |