class Events::SingleSubscriberEvent

An event with a single subscriber

Public Instance Methods

add_callback(&proc) click to toggle source

Override of Event.add_callback

Calls superclass method Events::Event#add_callback
# File lib/events.rb, line 61
def add_callback(&proc)
  if callbacks.length == 1
    raise EventSubscriptionError, "Cannot add more than one callback to SingleSubscriberEvent"
  end

  super
end
fire(*args) click to toggle source

Override of Event.fire

Calls superclass method Events::Event#fire
# File lib/events.rb, line 70
def fire(*args)
  packed_result = super
  if packed_result.length == 0
    return nil
  else
    return packed_result.first
  end
end