Skip to content

Instantly share code, notes, and snippets.

@jmettraux

jmettraux/t5.rb Secret

Created July 20, 2013 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmettraux/d0c9b036e7a515eccab0 to your computer and use it in GitHub Desktop.
Save jmettraux/d0c9b036e7a515eccab0 to your computer and use it in GitHub Desktop.
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