Class: SuperPoller::Router

Inherits:
Object
  • Object
show all
Defined in:
lib/super_poller/router.rb

Constant Summary collapse

RoutingError =
Class.new(Exception)

Instance Method Summary collapse

Constructor Details

#initializeRouter

Returns a new instance of Router.



4
5
6
# File 'lib/super_poller/router.rb', line 4

def initialize()
  @handlers = []
end

Instance Method Details

#add_handler(handler) ⇒ Object Also known as: <<



8
9
10
11
12
# File 'lib/super_poller/router.rb', line 8

def add_handler(handler)
  @handlers.push handler
  @handlers.uniq!
  self
end

#call(message) ⇒ Object



16
17
18
19
# File 'lib/super_poller/router.rb', line 16

def call(message)
  handler = best_handler_for_message(message)
  handler.call(message[:body])
end