Class: Hx::Interop::RPC::Dispatcher
- Inherits:
-
Object
- Object
- Hx::Interop::RPC::Dispatcher
- Defined in:
- lib/interop/rpc/dispatcher.rb
Overview
Message dispatcher used by Client and Server.
Defined Under Namespace
Classes: Route
Instance Method Summary collapse
- #dispatch(message) ⇒ Object (also: #<<)
-
#initialize ⇒ Dispatcher
constructor
A new instance of Dispatcher.
- #match(message) ⇒ Object
- #on(criteria, *handler, &block) ⇒ Object
Constructor Details
#initialize ⇒ Dispatcher
Returns a new instance of Dispatcher.
18 19 20 |
# File 'lib/interop/rpc/dispatcher.rb', line 18 def initialize @routes = [] end |
Instance Method Details
#dispatch(message) ⇒ Object Also known as: <<
29 30 31 32 33 34 |
# File 'lib/interop/rpc/dispatcher.rb', line 29 def dispatch() @routes.each do |route| route.call if route.match? end self end |
#match(message) ⇒ Object
36 37 38 |
# File 'lib/interop/rpc/dispatcher.rb', line 36 def match() @routes.find { |r| r.match? } end |