class Wisper::ObjectRegistration

Public Instance Methods

broadcast(event, publisher, *args) click to toggle source

For the registration to broadcast a specified event we require:

- 'should_broadcast?'    - If the listener susbcribed with an ':on' option, ensure that the event
                           is included in the 'on' list.
- 'listener.respond_to?' - The listener contains a handler for the event
- 'publisher_in_scope'   - If the listener subscribed with a ':scope' option, ensure that the
                           publisher's class is included in the 'scope' list.
# File lib/fragmentary/publisher.rb, line 69
def broadcast(event, publisher, *args)
  method_to_call = map_event_to_method(event)
  if should_broadcast?(event) && listener.respond_to?(method_to_call) && publisher_in_scope?(publisher)
    broadcaster.broadcast(listener, publisher, method_to_call, args)
  end
end

Private Instance Methods

publisher_in_scope?(publisher) click to toggle source
# File lib/fragmentary/publisher.rb, line 78
def publisher_in_scope?(publisher)
  allowed_classes.empty? || (allowed_classes.include? publisher.class.name)
end