class Tango::ETL::Dispatcher
Dispatcher
of handlers
@author Mckomo
Public Class Methods
new()
click to toggle source
# File lib/tango/etl/dispatcher.rb, line 9 def initialize @handlers = [] end
Public Instance Methods
find_handler( url )
click to toggle source
Find first applicable handler
@param url [String] URL of the page to be handled @return [HandlerInterface]
# File lib/tango/etl/dispatcher.rb, line 35 def find_handler( url ) # Iterate handlers to find first matching handler @handlers.each do |h| return h if h.applicable?( url ) end nil end
register( handler_class )
click to toggle source
Register new handler
@param handler_class [HandlerInterface] Class that implements HandlerInterface
@return [Dispatcher]
# File lib/tango/etl/dispatcher.rb, line 17 def register( handler_class ) # handler must implement HandlerInterface unless handler_class.ancestors.include? Tango::ETL::HandlerInterface raise "Handler must implement HandlerInterface" end # Append handler to container @handlers << handler_class self # Chainabilty! end