lib/ruote/exp/fe_iterator.rb in ruote-2.1.10 vs lib/ruote/exp/fe_iterator.rb in ruote-2.1.11

- old
+ new

@@ -76,10 +76,21 @@ # participant 'accounting' # end # end # # + # == the classical case + # + # Iterating over a workitem field : + # + # pdef = Ruote.process_definition :name => 'test' do + # iterator :on_field => 'customers', :to_f => 'customer' + # participant '${f:customer}' + # end + # end + # + # # == break/rewind/continue/skip/jump # # The 'iterator' expression understands a certain the following commands : # # * break (_break) : exits the iteration @@ -94,9 +105,38 @@ # participant 'accounting', :review => '${v:i}' # rewind :if => '${f:redo_everything} == true' # end # end # end + # + # == iterator command in the workitem + # + # It's OK to issue a command to the iterator from a participant via the + # workitem. + # + # pdef = Ruote.process_definition do + # iterator :times => 10 + # sequence do + # participant 'accounting' + # participant 'adjust' + # end + # end + # end + # + # where + # + # class Adjust + # include Ruote::LocalParticipant + # def consume (workitem) + # workitem.command = 'break' if workitem.fields['amount'] > 10_000 + # reply_to_engine(workitem) + # end + # def cancel (fei, flavour) + # end + # end + # + # A completely stupid example... The adjust participant will make the + # loop break if the amount reaches 10_000 (euros?). # # # == break/rewind/continue/skip/jump with :ref # # An iterator can be tagged (with the :tag attribute) and directly referenced