Class: Ruote::Exp::LoseExpression
- Inherits:
-
FlowExpression
- Object
- FlowExpression
- Ruote::Exp::LoseExpression
- Defined in:
- lib/ruote/exp/fe_lose.rb
Overview
Never replies to its parent expression. Simply applies its first child, if any, and just sits there.
When cancelled, cancels its child (if any).
In this example, the reminding sequence never replies to the concurrence. The concurrence is only over when “alfred” replies.
Ruote.process_definition do
concurrence :count => 1 do
alfred
lose do
sequence do
wait '2d'
send_reminder_to_alfred
wait '2h'
send_alarm_to_boss
end
end
end
end
Maybe shorter :
Ruote.process_definition do
concurrence :count => 1 do
alfred
sequence do
wait '2d'
send_reminder_to_alfred
wait '2h'
send_alarm_to_boss
lose
end
end
end
‘lose’ on its own acts like a dead-end.
the :lose attribute
Every expression understands the ‘lose’ attribute :
Ruote.process_definition do
concurrence :count => 1 do
alfred
sequence :lose => true do
wait '2d'
send_reminder_to_alfred
wait '2h'
send_alarm_to_boss
end
end
end
Probably produces definitions more compact than when using the ‘lose’ expression.
forget vs lose
forget : replies to parent expression immediately, is not cancellable (not reachable).
lose : never replies to parent expression, is cancellable.
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
99 100 101 102 |
# File 'lib/ruote/exp/fe_lose.rb', line 99 def apply apply_child(0, h.applied_workitem) end |
#reply(workitem) ⇒ Object
104 105 106 107 |
# File 'lib/ruote/exp/fe_lose.rb', line 104 def reply(workitem) # never gets called end |