Class: Ruote::Exp::SequenceExpression

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

Overview

The plain 'sequence' expression.

sequence do
  participant 'alpha'
  participant 'bravo'
  participant 'charly'
end

using 'let'

'let' behaves like a sequence, but the children have their own variable scope.

pdef = Ruote.process_definition do
  set 'v:var' => 'val'
  echo "out:${v:var}"
  let do
    set 'v:var' => 'val1'
    echo "in:${v:var}"
  end
  echo "out:${v:var}"
end

# => out:val, in:val1, out:val

as a 'case' statement

let do
  define 'published' do
    do_this
  end
  define 'reviewed' do
    do_that
  end
  subprocess '${case}'
end

Subprocesses 'published' and 'reviewed' are bound in a local scope, that gets discarded when the let exits.

Constant Summary

Constants inherited from FlowExpression

FlowExpression::COMMON_ATT_KEYS

Instance Attribute Summary

Attributes inherited from FlowExpression

#context, #error

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

#h, #h=, included, #to_h

Constructor Details

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

Instance Method Details

#applyObject


75
76
77
78
79
80
# File 'lib/ruote/exp/fe_sequence.rb', line 75

def apply

  h.variables ||= {} if name == 'let'

  reply(h.applied_workitem)
end

#reply(workitem) ⇒ Object


82
83
84
85
86
87
88
89
90
91
92
# File 'lib/ruote/exp/fe_sequence.rb', line 82

def reply(workitem)

  position = workitem['fei'] == h.fei ?
    0 : Ruote::FlowExpressionId.new(workitem['fei']).child_id + 1

  if position < tree_children.size
    apply_child(position, workitem)
  else
    reply_to_parent(workitem)
  end
end