def on(*events, &callback)
      fail '.on requires an event' if events.size == 0

      listener = Listener.new(self, events, callback)

      @listeners ||= {}

      events.each do |event|
        event             = event.to_sym
        @listeners[event] ||= []
        @listeners[event] << listener

        first_for_event = @listeners[event].size == 1
        first           = first_for_event && @listeners.size == 1

        # Let the included class know that an event was registered. (if it cares)
        if self.respond_to?(:event_added)
          # call event added passing the event, the scope, and a boolean if it
          # is the first time this event has been added.
          event_added(event, first, first_for_event)
        end
      end

      listener
    end
def on(*events, &callback)
      fail '.on requires an event' if events.size == 0

      listener = Listener.new(self, events, callback)

      @listeners ||= {}

      events.each do |event|
        event             = event.to_sym
        @listeners[event] ||= []
        @listeners[event] << listener

        first_for_event = @listeners[event].size == 1
        first           = first_for_event && @listeners.size == 1

        # Let the included class know that an event was registered. (if it cares)
        if self.respond_to?(:event_added)
          # call event added passing the event, the scope, and a boolean if it
          # is the first time this event has been added.
          event_added(event, first, first_for_event)
        end
      end

      listener
    end
Sets up a listener on the class the Eventable module was included in.
 event should be a string or symbol.  When something calls #trigger!(event_name) on
 the class, it will trigger any listener with the same event name.

 returns: a listener that has a #remove method to stop the listener.