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



24
25
26
# File 'lib/mongo/event/subscriber.rb', line 24

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



35
36
37
# File 'lib/mongo/event/subscriber.rb', line 35

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