module Mongo::Event::Publisher

This module is included for objects that need to publish events.

@since 2.0.0

Attributes

event_listeners[R]

@return [ Event::Listeners ] event_listeners The listeners.

Public Instance Methods

publish(event, *args) click to toggle source

Publish the provided event.

@example Publish an event.

publisher.publish("my_event", "payload")

@param [ String ] event The event to publish. @param [ Array<Object> ] args The objects to pass to the listeners.

@since 2.0.0

# File lib/mongo/event/publisher.rb, line 35
def publish(event, *args)
  event_listeners.listeners_for(event).each do |listener|
    listener.handle(*args)
  end
end