Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
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
You can’t perform that action at this time.