lib/ruote/exp/fe_concurrent_iterator.rb in ruote-2.1.11 vs lib/ruote/exp/fe_concurrent_iterator.rb in ruote-2.2.0

- old
+ new

@@ -1,7 +1,7 @@ #-- -# Copyright (c) 2005-2010, John Mettraux, jmettraux@gmail.com +# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell @@ -110,27 +110,38 @@ # In this example, if the process level variable 'not_sufficient' is set to # true, workers d and e will be added to the iterated elements. # # Read more at the 'add_branches' expression description. # + # + # == 'citerator' + # + # 'citerator' is an alias for 'concurrent_iterator'. + # + # pdef = Ruote.process_definition :name => 'test' do + # citerator :on_val => 'alice, bob, charly', :to_var => 'v' do + # participant '${v:v}' + # end + # end + # class ConcurrentIteratorExpression < ConcurrenceExpression include IteratorMixin - names :concurrent_iterator + names :concurrent_iterator, :citerator ADD_BRANCHES_FIELD = '__add_branches__' # Overrides FlowExpression#register_child to make sure that persist is # not called. # - def register_child (fei) + def register_child(fei) h.children << fei end - def add_branches (list) + def add_branches(list) if h.times_iterator && list.size == 1 count = (list.first.to_i rescue nil) @@ -140,10 +151,11 @@ list.each do |val| h.list_size += 1 workitem = Ruote.fulldup(h.applied_workitem) + #workitem = Rufus::Json.dup(h.applied_workitem) variables = { 'ii' => h.list_size - 1 } if h.to_v variables[h.to_v] = val @@ -157,10 +169,10 @@ :workitem => workitem, :variables => variables) end end - def reply (workitem) + def reply(workitem) if ab = workitem['fields'].delete(ADD_BRANCHES_FIELD) add_branches(ab)