class Aesop::Dispatcher
Public Class Methods
new()
click to toggle source
# File lib/aesop/dispatcher.rb, line 11 def initialize collect_dispatchers end
Public Instance Methods
collect_dispatchers()
click to toggle source
# File lib/aesop/dispatcher.rb, line 31 def collect_dispatchers configuration.dispatchers.each do |dispatch_symbol| instance = instantiate_dispatcher( dispatch_symbol ) register_dispatcher(instance) end end
dispatch_exception(exception)
click to toggle source
# File lib/aesop/dispatcher.rb, line 15 def dispatch_exception(exception) dispatchers.each do |dispatcher| begin Aesop::Logger.debug("#{dispatcher.class.to_s}: dispatching #{exception.class.to_s}") dispatcher.dispatch_exception(exception) rescue => e Aesop::Logger.error( "Exception in #{dispatcher.class.to_s}: Exception: #{exception.class.to_s}. Trying to dispatch: #{e.class.to_s}: #{e.message}" ) end end end
dispatchers()
click to toggle source
# File lib/aesop/dispatcher.rb, line 42 def dispatchers @dispatchers ||= [] end
instantiate_dispatcher( symbol )
click to toggle source
# File lib/aesop/dispatcher.rb, line 26 def instantiate_dispatcher( symbol ) Aesop::Logger.debug("Instantiating #{to_classname(symbol)}") Aesop::Dispatchers.const_get( to_classname(symbol) ).new end
register_dispatcher( dispatcher )
click to toggle source
# File lib/aesop/dispatcher.rb, line 38 def register_dispatcher( dispatcher ) dispatchers << dispatcher end
to_classname(symbol)
click to toggle source
# File lib/aesop/dispatcher.rb, line 46 def to_classname(symbol) symbol.to_s.split(/[-_]/).map(&:capitalize).join end