lib/eventable/eventable.rb
# Allows objects to stop listening to events
Allows objects to stop listening to events
Allows objects to stop listening to events
def unregister_for_event(args)
    check_mutex
    @eventable_mutex.synchronize {
      event = args[:event]
      return unless @callbacks && @callbacks[event]
      listener_id = args[:listener_id] || args[:listener].object_id
      callback    = args[:callback]
      @callbacks[event].delete_if do |listener, callbacks|
        callbacks.delete(callback) if listener == listener_id
        callbacks.empty?
      end
    }
  end
def unregister_for_event ( args ) check_mutex @eventable_mutex . synchronize { event = args [ :event ] return unless @callbacks && @callbacks [ event ] listener_id = args [ :listener_id ] || args [ :listener ] . object_id callback = args [ :callback ] @callbacks [ event ] . delete_if do | listener , callbacks | callbacks . delete ( callback ) if listener == listener_id callbacks . empty? end } end
Allows objects to stop listening to events
Allows objects to stop listening to events
args