Class: Ruote::Exp::UndoExpression

Inherits:
FlowExpression show all
Defined in:
lib/ruote/exp/fe_undo.rb

Overview

Undoes (cancels) another expression referred by its tag.

pdef = Ruote.process_definition do
  concurrence do
    alpha :tag => 'kilroy'
    undo :ref => 'kilroy'
  end
end

This example is rather tiny, but it shows a process branch (undo) cancelling another (alpha).

cancel

This expression is aliased to ‘cancel’

cancel :ref => 'invoicing_stage'

a bit shorter

It’s OK to shorten

cancel :ref => 'invoicing_stage'

to

cancel 'invoicing_stage'

kill

kill :ref => 'invoicing stage'

will cancel the target expression and bypass any on_cancel handler set for it.

concurrence do
  sequence :tag => 'x', :on_cancel => 'y' do
    # ...
  end
  sequence do
    # ...
    kill 'x'
  end
end

In this example the :on_cancel => ‘y’ will get ignored if kill ‘x’ kicks in.

Constant Summary

Constants inherited from FlowExpression

FlowExpression::COMMON_ATT_KEYS

Instance Attribute Summary

Attributes inherited from FlowExpression

#context, #error, #h

Instance Method Summary collapse

Methods inherited from FlowExpression

#ancestor?, #applied_workitem, #att, #att_text, #attribute, #attribute_text, #attributes, #await, #cancel, #cancel_flanks, #cfei_at, #child_id, #child_ids, #compile_atts, #compile_variables, #debug_id, #deflate, #do, do_action, #do_apply, #do_cancel, #do_fail, #do_pause, #do_persist, #do_reply, #do_reply_to_parent, #do_resume, #do_unpersist, dummy, #fei, fetch, from_h, #handle_on_error, #has_attribute, #initial_persist, #initialize, #is_concurrent?, #iterative_var_lookup, #launch_sub, #lookup_val, #lookup_val_prefix, #lookup_variable, #name, names, #parent, #parent_id, #pause_on_apply, #persist_or_raise, #reply_to_parent, #root, #root_id, #set_variable, #to_h, #tree, #tree_children, #try_persist, #try_unpersist, #unpersist_or_raise, #unset_variable, #update_tree, #variables, #wfid

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

#applyObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/ruote/exp/fe_undo.rb', line 81

def apply

  ref = attribute(:ref) || attribute_text
  ref = ref.strip if ref

  tag = (ref && ref != '') ? lookup_variable(ref) : nil

  @context.storage.put_msg(
    'cancel',
    'fei' => tag,
    'flavour' => self.name == 'kill' ? 'kill' : nil
  ) if Ruote.is_a_fei?(tag)

  reply_to_parent(h.applied_workitem)
end

#reply(workitem) ⇒ Object



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

def reply(workitem)

  # never called
end