Class: Ruote::Observer
- Inherits:
-
Object
- Object
- Ruote::Observer
- Defined in:
- lib/ruote/observer.rb
Overview
An abstract class for observing the activity of a ruote engine.
Subclass it and add it as a service to observe certain events.
require 'ruote/observer'
class MyLaunchObserver < Ruote::Observer
def on_msg_launch(msg)
puts "just launched process instance #{msg['wfid']}"
end
end
dashboard.add_service('launch_observer', MyLaunchObserver)
# ...
Simply add a “on_msg_<msg_name>” method for it to intercept the given messages.
See Ruote::ProcessObserver for a base class with precisely defined methods with helpful arguments if you don’t want to investigate “msgs” too much.
Instance Method Summary collapse
-
#initialize(context) ⇒ Observer
constructor
A new instance of Observer.
- #on_msg(msg) ⇒ Object
- #on_pre_msg(msg) ⇒ Object
Constructor Details
#initialize(context) ⇒ Observer
Returns a new instance of Observer.
55 56 57 58 |
# File 'lib/ruote/observer.rb', line 55 def initialize(context) @context = context end |
Instance Method Details
#on_msg(msg) ⇒ Object
65 66 67 68 |
# File 'lib/ruote/observer.rb', line 65 def on_msg(msg) route(nil, msg) end |
#on_pre_msg(msg) ⇒ Object
60 61 62 63 |
# File 'lib/ruote/observer.rb', line 60 def on_pre_msg(msg) route('pre', msg) end |