Class: Ruote::Exp::CommandedExpression

Inherits:
FlowExpression show all
Includes:
CommandMixin
Defined in:
lib/ruote/exp/commanded.rb

Overview

A parent class for CursorExpression and IteratorExpression

Direct Known Subclasses

CursorExpression, IteratorExpression

Constant Summary

Constants included from CommandMixin

Ruote::Exp::CommandMixin::ATT_COMMANDS, Ruote::Exp::CommandMixin::F_COMMAND

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

#reply(workitem) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ruote/exp/commanded.rb', line 39

def reply(workitem)

  workitem = h.command_workitem || workitem
  h.command_workitem = nil

  # command/answer may come from
  #
  # a) a child, regular case, easy
  # b) somewhere else, which means we have to cancel the current child
  #    and then make sure the comand is interpreted

  # a)

  if Ruote::FlowExpressionId.direct_child?(h.fei, workitem['fei'])
    return move_on(workitem)
  end

  # b)

  h.command_workitem = workitem
  h.command_workitem['fei'] = h.children.first

  do_persist or return

  @context.storage.put_msg('cancel', 'fei' => h.children.first)

  # iteration will be done at when cancelled child replies
end