Ravn::Actor::
MessageHandling module
This is a mixin that adds the core message-dispatch mechanism for Ravn
event systems to an Actor
.
After extending an Actor
with MessageHandling
, you can declare handlers for particular kinds of messages using the ::register_message_handler declaration:
class Acme::Object extend Ravn::Actor::MessageHandling
def handle_gps_message( message ) # ...handle messages from GPS end register_message_handler( 'net.gps.', 'sys.gps.', :handle_gps_message )
end
This will cause any message whose type begins with either prefix that is passed to the filter_down method to call the handler method before calling the extended class’s filter_down.
If there are several handlers, the handler associated with the longest matching prefix is called.
You can also declare the handler inline like so:
register_message_handler
‘net.gps.’, ‘sys.gps.’, def handle_gps_message( message ) # …handle messages from GPS end