def publish(event, *args)
      raise ArgumentError, "#{self.class} does not handle #{event.inspect}" unless events.include? event

      # Do nothing if the object is disabled.
      return if respond_to?(:enabled?) and not enabled?

      if respond_to? event
        return :handled if send(event, self, *args) == :handled
      end

      if defined? @_event_handlers
        @_event_handlers[event].reverse_each do |handler|
          return :handled if handler.call(self, *args) == :handled
        end
      end

      nil
    end
def publish(event, *args)
      raise ArgumentError, "#{self.class} does not handle #{event.inspect}" unless events.include? event

      # Do nothing if the object is disabled.
      return if respond_to?(:enabled?) and not enabled?

      if respond_to? event
        return :handled if send(event, self, *args) == :handled
      end

      if defined? @_event_handlers
        @_event_handlers[event].reverse_each do |handler|
          return :handled if handler.call(self, *args) == :handled
        end
      end

      nil
    end
Publish an event to all previously added handlers in the order they were added.
 It will automatically call the publishing object with the method named after the event if it is defined
 (this will be done before the manually added handlers are called).

 If any handler returns :handled, then no further handlers will be called.

 @param [Symbol] event Name of the event to publish.
 @param [Array] args Arguments to pass to the event handlers.
 @return [Symbol, nil] :handled if any handler handled the event or nil if none did.