Skip to content

Instantly share code, notes, and snippets.

@kennethkalmer
Created October 21, 2010 10:34
Show Gist options
  • Save kennethkalmer/638269 to your computer and use it in GitHub Desktop.
Save kennethkalmer/638269 to your computer and use it in GitHub Desktop.
Ruote.process_defition :name => 'Hello world' do
cursor :break_if => "${f:error}" do
foo :command => '/verify/something'
bar :command => '/report'
end
end
class BaseParticipant
include Ruote::LocalParticipant
def consume( workitem )
@workitem = workitem
begin
_, method, arg = workitem.fields['command'].split('/')
if arg
send( method, arg )
else
send( method )
end
rescue => e
@workitem.fields['error'] = e
reply_to_engine( @workitem )
end
end
def done( message )
@workitem.fields['report'].push message
reply_to_engine( @workitem )
end
def failed( message )
@workitem.fields['report'].push message
@workitem.fields['error'] = true
reply_to_engine( @workitem )
end
end
class Foo < BaseParticipant
def verify( something )
# Do something
done "It worked"
end
end
class Bar < BaseParticipant
def report
# Oh well
failed "No way I'm doing this"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment