Created
October 21, 2010 10:34
-
-
Save kennethkalmer/638269 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.process_defition :name => 'Hello world' do | |
cursor :break_if => "${f:error}" do | |
foo :command => '/verify/something' | |
bar :command => '/report' | |
end | |
end |
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
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