lib/marvin/dispatchable.rb in jeffrafter-marvin-0.1.20081115 vs lib/marvin/dispatchable.rb in jeffrafter-marvin-0.1.20081120

- old
+ new

@@ -24,13 +24,15 @@ end module InstanceMethods # Returns the handlers registered on this class, - # used inside +dispatch+. + # used inside +dispatch+. Note that it will call + # dup on each of the objects to get a new instance. + # please ensure your object acts accordingly. def handlers - self.class.handlers + @handlers ||= self.class.handlers.map { |h| h.dup } end # Dispatch an 'event' with a given name to the handlers # registered on the current class. Used as a nicer way of defining # behaviours that should occur under a given set of circumstances. @@ -51,19 +53,22 @@ # is the only required aspect of a handler. An improved # version of this would likely cache the respond_to? # call. self.handlers.each do |handler| if handler.respond_to?(full_handler_name) - handler.sent(full_handler_name, opts) + handler.send(full_handler_name, opts) else handler.handle name, opts end end # If we get the HaltHandlerProcessing exception, we # catch it and continue on our way. In essence, we # stop the dispatch of events to the next set of the # handlers. - rescue HaltHandlerProcessing + rescue HaltHandlerProcessing => e + Marvin::Logger.info "Halting processing chain" + rescue Exception => e + Marvin::ExceptionTracker.log(e) end end module ClassMethods \ No newline at end of file