Class OpenWFE::UndoExpression
In: lib/openwfe/expressions/fe_do.rb
Parent: FlowExpression

Every expression in OpenWFEru accepts a ‘tag’ attribute. This tag can later be referenced by an ‘undo’ or ‘redo’ expression. Tags are active as soon as an expression is applied and they vanish when the expression replies to its parent expression or is cancelled.

Calling for the undo of a non-existent tag throws no error, the flow simply resumes.

    concurrence do
        sequence :tag => "side_job" do
            participant "alice"
            participant "bob"
        end
        sequence do
            participant "charly"
            undo :ref => "side_job"
        end
    end

In this example, as soon as the participant charly is over, the sequence ‘side_job’ gets undone (cancelled). If the sequence ‘side_job’ was already over, the "undo" will have no effect.

Methods

Public Instance methods

[Source]

    # File lib/openwfe/expressions/fe_do.rb, line 78
78:         def apply (workitem)
79: 
80:             tag = lookup_tag(workitem)
81: 
82:             undo_self = false
83: 
84:             if tag
85:                 #OpenWFE::call_in_thread(fei.expression_name, self) do
86:                 process_tag tag
87:                 #end
88: 
89:                 undo_self = tag.fei.ancestor_of?(@fei)
90:             end
91: 
92:             reply_to_parent(workitem) unless undo_self
93:         end

Calls the expression pool cancel() method upon the tagged expression.

[Source]

     # File lib/openwfe/expressions/fe_do.rb, line 99
 99:         def process_tag (tag)
100: 
101:             ldebug do
102:                 "process_tag() #{fei.to_debug_s} to undo #{tag.fei.to_debug_s}"
103:             end
104: 
105:             #get_expression_pool.cancel_and_reply_to_parent(
106:             #    tag.raw_expression.fei, tag.workitem)
107: 
108:             exp = get_expression_pool.fetch_expression(tag.raw_expression.fei)
109: 
110:             get_expression_pool.cancel(tag.raw_expression.fei)
111: 
112:             get_expression_pool.reply_to_parent(exp, tag.workitem, false)
113:                 #
114:                 # 'remove' is set to false, cancel already removed the
115:                 # expression
116:         end

Protected Instance methods

def reply (workitem) end

[Source]

     # File lib/openwfe/expressions/fe_do.rb, line 123
123:             def lookup_tag (workitem)
124: 
125:                 tagname = lookup_attribute :ref, workitem
126: 
127:                 tag = lookup_variable tagname
128: 
129:                 lwarn { "lookup_tag() no tag named '#{tagname}' found" } \
130:                     unless tag
131: 
132:                 tag
133:             end

[Validate]