Class: Ruote::Exp::CommandExpression
- Inherits:
-
FlowExpression
- Object
- FlowExpression
- Ruote::Exp::CommandExpression
- Includes:
- CommandMixin
- Defined in:
- lib/ruote/exp/fe_command.rb
Overview
This class gathers the ‘skip’, ‘back’, ‘jump’, ‘rewind’, ‘continue’, ‘reset’ and ‘break’ expressions which are used inside of the ‘cursor’ and ‘repeat’ (loop) expressions.
Look at the ‘cursor’ expression Ruote::Exp::Cursor for a discussion of each of those [sub]expressions.
The expression that understand commands are ‘cursor’, ‘repeat’ (‘loop’) and ‘iterator’. ‘concurrent_iterator’ does not understand commands since it fires all its branches when applied.
:ref => ‘tag’
It’s OK to tag a cursor/loop/iterator with the :tag attribute and then point a command to it via :ref :
concurrence do
cursor :tag => 'main' do
editor
publisher
end
# meanwhile ...
sequence do
sponsor
rewind :ref => 'main', :if => '${f:stop}'
end
end
This :ref technique may also be used with nested cursor/loop/iterator constructs :
cursor :tag => 'main' do
cursor do
editor
rewind :if => '${f:not_ok}'
_break :ref => 'main', :if => '${f:abort_everything}'
end
head_of_edition
rewind :if => '${f:not_ok}'
publisher
end
this example features two nested cursors. There is a “_break” in the inner cursor, but it will break the main ‘cursor’ (and thus break the whole review process).
:ref works with the ‘iterator’ expression as well.
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
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_pause, #do_persist, #do_reply, #do_resume, #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, #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
Methods included from WithH
Constructor Details
This class inherits a constructor from Ruote::Exp::FlowExpression
Instance Method Details
#apply ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/ruote/exp/fe_command.rb', line 92 def apply param = case name when 'skip', 'back' then attribute(:step) || attribute_text when 'jump' then attribute(:to) || attribute_text else nil end param = Integer(param) rescue param command_workitem = Ruote.fulldup(h.applied_workitem) set_command(command_workitem, name, param) target = parent ancestor = true if ref = attribute(:ref) fei = lookup_variable(ref) target = Ruote::FlowExpressionId.is_a_fei?(fei) ? Ruote::Exp::FlowExpression.fetch(@context, fei) : nil target = target.is_a?(Ruote::Exp::CommandedExpression) ? target : nil ancestor = target ? ancestor?(target.h.fei) : false else target = fetch_command_target end return reply_to_parent(h.applied_workitem) if target.nil? return reply_to_parent(command_workitem) if target.h.fei == h.parent_id @context.storage.put_msg( 'reply', 'fei' => target.h.fei, 'workitem' => command_workitem, 'command' => [ name, param ]) # purely indicative for now reply_to_parent(h.applied_workitem) unless ancestor end |