Module: Mongo::Event::Subscriber

Included in:
Cluster
Defined in:
lib/mongo/event/subscriber.rb

Overview

Adds convenience methods for adding listeners to event publishers.

Since:

  • 2.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#event_listenersEvent::Listeners (readonly)

Returns event_listeners The listeners.

Returns:

Since:

  • 2.0.0



27
28
29
# File 'lib/mongo/event/subscriber.rb', line 27

def event_listeners
  @event_listeners
end

Instance Method Details

#subscribe_to(event, listener) ⇒ Object

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



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

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