lib/ruote/exp/fe_apply.rb in ruote-2.1.9 vs lib/ruote/exp/fe_apply.rb in ruote-2.1.10
- old
+ new
@@ -53,15 +53,84 @@
# All are equivalent to
#
# echo 'nada'
#
#
+ # == apply and subprocesses
+ #
+ # There is an interesting way of using 'apply', it's close to the way of
+ # the Ruby "yield" expression.
+ #
+ # pdef = Ruote.process_definition 'test' do
+ # sequence do
+ # handle do
+ # participant 'alpha'
+ # end
+ # handle do
+ # participant 'bravo'
+ # end
+ # end
+ # define 'handle' do
+ # sequence do
+ # participant 'prepare_data'
+ # apply
+ # participant 'rearrange_data'
+ # end
+ # end
+ # end
+ #
+ # With this process definition, the particpant alpha and bravo are handed
+ # a workitem in sequence, but each time, the data gets prepared and
+ # re-arranged.
+ #
+ # 'apply' simply picks the value of the tree to apply in the local variable
+ # 'tree'.
+ #
+ # Passing variables to applied trees is possible :
+ #
+ # pdef = Ruote.process_definition do
+ # handle do
+ # participant '${v:target}', :message => 'x'
+ # end
+ # define 'handle' do
+ # sequence do
+ # participant 'prepare_data'
+ # apply :v => 'alpha'
+ # apply :v => 'bravo'
+ # participant 'rearrange_data'
+ # end
+ # end
+ # end
+ #
+ #
+ # == on_error
+ #
+ # It's OK, to place an on_error on the apply
+ #
+ # pdef = Ruote.process_definition do
+ # handle do
+ # sequence do
+ # echo 'in'
+ # nemo
+ # end
+ # end
+ # define 'handle' do
+ # apply :on_error => 'notify' # <==
+ # echo 'over.'
+ # end
+ # define 'notify' do
+ # echo 'error'
+ # end
+ # end
+ #
class ApplyExpression < FlowExpression
names :apply
# TODO : maybe accept directly ruby and xml (and json)
# TODO : _yield ?
+
+ # TODO : apply [ 'echo', { 'nada' => nil }, [] ]
def apply
#
# find 'tree'