Created
July 27, 2012 08:03
-
-
Save coffeeaddict/3186751 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
class PreferedImplementation < Ruote::ProcessObserver | |
def on_launch(wfid, workitem, variables) # stash and pdef could also be there | |
$stderr.puts "Hey! #{wfid} started with #{workitem.fields}" | |
end | |
def on_end(wfid, workitem) | |
$stderr.puts "#{wfid} finaly made it! (the workitem ended up as #{workitem.fields})" | |
end | |
def on_flunk(wfid, workitem, error) | |
$stderr.puts "Hey, #{wfid} flunked with #{error.class.name}: #{error.message} - looking like #{workitem.fields}" | |
end | |
def on_cancel(wfid, workitem) | |
$stderr.puts "To bad... #{wfid} got canceled" | |
end | |
def on_step(wfid, workitem) | |
$stderr.puts "I'm just a simplified version of on_msg called when the participant changes ;)" | |
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
module Ruote | |
# take on_msg and translate it into more detailed actions | |
class ProcessObserver | |
attr_accessor :context, :options | |
def initialize(context, options) | |
@context = context; @option = options | |
end | |
def on_msg(msg) | |
case msg['action'] | |
when 'launch' | |
on_laucnh(msg) | |
# ... etc ... | |
end | |
end | |
def on_launch(msg) | |
end | |
def on_end(msg) # or on_terminate | |
end | |
def on_flunk(msg) | |
end | |
def on_cancel(msg) | |
end | |
def on_step(msg) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment