123456789_123456789_123456789_123456789_123456789_

Module: Mongo::Event::Publisher

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/mongo/event/publisher.rb

Overview

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

Since:

  • 2.0.0

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#event_listenersEvent::Listeners (readonly)

Returns:

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/event/publisher.rb', line 27

attr_reader :event_listeners

Instance Method Details

#publish(event, *args)

Publish the provided event.

Examples:

Publish an event.

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

Parameters:

  • event (String)

    The event to publish.

  • args (Array<Object>)

    The objects to pass to the listeners.

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/event/publisher.rb', line 38

def publish(event, *args)
  event_listeners.listeners_for(event).each do |listener|
    listener.handle(*args)
  end
end