Class: Ruote::Exp::LoseExpression

Inherits:
FlowExpression show all
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.

Constant Summary

Constant Summary

Constants inherited from FlowExpression

FlowExpression::COMMON_ATT_KEYS

Instance Attribute Summary

Attributes inherited from FlowExpression

#context, #h

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_persist, #do_reply, #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

#class_def, included

Methods included from WithH

included

Constructor Details

This class inherits a constructor from Ruote::Exp::FlowExpression

Instance Method Details

- (Object) apply



92
93
94
95
# File 'lib/ruote/exp/fe_lose.rb', line 92

def apply

  apply_child(0, h.applied_workitem)
end

- (Object) reply(workitem)



97
98
99
100
# File 'lib/ruote/exp/fe_lose.rb', line 97

def reply(workitem)

  # never gets called
end