Class: Mongo::Event::Listeners
- Inherits:
-
Object
- Object
- Mongo::Event::Listeners
- Defined in:
- lib/mongo/event/listeners.rb
Overview
The queue of events getting processed in the client.
Instance Method Summary collapse
-
#add_listener(event, listener) ⇒ Array<Object>
Add an event listener for the provided event.
-
#initialize ⇒ Listeners
constructor
Initialize the event listeners.
-
#listeners_for(event) ⇒ Array<Object>
Get the listeners for a specific event.
Constructor Details
#initialize ⇒ Listeners
Initialize the event listeners.
32 33 34 |
# File 'lib/mongo/event/listeners.rb', line 32 def initialize @listeners = {} end |
Instance Method Details
#add_listener(event, listener) ⇒ Array<Object>
Add an event listener for the provided event.
47 48 49 |
# File 'lib/mongo/event/listeners.rb', line 47 def add_listener(event, listener) listeners_for(event).push(listener) end |
#listeners_for(event) ⇒ Array<Object>
Get the listeners for a specific event.
61 62 63 |
# File 'lib/mongo/event/listeners.rb', line 61 def listeners_for(event) @listeners[event] ||= [] end |