Class: Ruote::Exp::ThatExpression
- Inherits:
-
SequenceExpression
- Object
- FlowExpression
- SequenceExpression
- Ruote::Exp::ThatExpression
- Defined in:
- lib/ruote/exp/fe_that.rb
Overview
The ‘that’ and the ‘of’ expressions are used in conjuction with the ‘given’ expression (GivenExpression).
In can be used ‘standalone’, it thus becomes then merely an ‘if’.
The children of the that/of are executed if the condition evaluates to true. The children are executed one by one, as if the that/of were a sequence.
given '${status}' do
that '${location} == CH' do
set 'f:bank' => 'UBS'
subprocess 'buy_chocolate'
end
of 'ready' do
participant 'saleshead', :msg => 'customer ready'
participant 'salesman', :task => 'visiter customer'
end
of 'over' do
participant 'manager', :msg => 'process over'
end
end
(Yes, I know, it’s a poor example).
Constant Summary
Constants inherited from FlowExpression
FlowExpression::COMMON_ATT_KEYS
Instance Attribute Summary
Attributes inherited from FlowExpression
Instance Method Summary collapse
Methods inherited from SequenceExpression
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, #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
#reply(workitem) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ruote/exp/fe_that.rb', line 60 def reply(workitem) if workitem['fei'] == h.fei # apply --> reply cond = attribute(:t) || attribute(:test) || attribute_text if name == 'of' comparator = cond.match(/^\s*\/.*\/\s*$/) ? '=~' : '==' cond = "#{workitem['fields']['__given__']} #{comparator} #{cond}" end h.result = Condition.true?(cond) if h.result apply_child(0, workitem) else reply_to_parent(workitem) end else # reply from child super end end |
#reply_to_parent(workitem) ⇒ Object
85 86 87 88 89 |
# File 'lib/ruote/exp/fe_that.rb', line 85 def reply_to_parent(workitem) workitem['fields']['__result__'] = h.result super end |