123456789_123456789_123456789_123456789_123456789_

Module: Mongo::Event::Subscriber

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

Overview

Adds convenience methods for adding listeners to event publishers.

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/subscriber.rb', line 27

attr_reader :event_listeners

Instance Method Details

#subscribe_to(event, listener)

Subscribe to the provided event.

Examples:

Subscribe to the event.

subscriber.subscribe_to('test', listener)

Parameters:

  • event (String)

    The event.

  • listener (Object)

    The event listener.

Since:

  • 2.0.0

[ GitHub ]

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

def subscribe_to(event, listener)
  event_listeners.add_listener(event, listener)
end