-
-
Save jmettraux/d0c9b036e7a515eccab0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ruote.define do | |
set 'f:participants' => [ "a", "b", "c" ] | |
# this participant distributes slots to the participants | |
# enumerated in the "participants" workitem field. | |
# | |
participant 'distributor' | |
citerator :on => "$f:participants", :to_var => 'v' do | |
# each participant picks up its slot in the workitem | |
# (as set by the "distributor" participant) | |
# | |
participant '$v:v', :task => 'do_the_job' | |
end | |
end | |
# | |
# example "distributor implementation" | |
# | |
class Distributor < Ruote::Participant | |
def on_workitem | |
workitem.fields['slots'] = {} | |
workitem.fields['participants'].each_with_index do |participant_name, i| | |
# i is a integer from 0 to workitem.fields['participants'].length | |
# just a silly idea | |
workitem.fields['slots'][participant_name] = i | |
end | |
reply # let this workitem go on in its workflow instance | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment