Class: Mongo::Event::Listeners
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/mongo/event/listeners.rb |
Overview
The queue of events getting processed in the client.
Class Method Summary
-
.new ⇒ Listeners
constructor
Initialize the event listeners.
Instance Method Summary
-
#add_listener(event, listener) ⇒ Array<Object>
Add an event listener for the provided event.
-
#listeners_for(event) ⇒ Array<Object>
Get the listeners for a specific event.
Constructor Details
.new ⇒ Listeners
Initialize the event listeners.
# 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.
# 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.
# File 'lib/mongo/event/listeners.rb', line 61
def listeners_for(event) @listeners[event] ||= [] end