Class: Hivent::Emitter
- Inherits:
-
Object
- Object
- Hivent::Emitter
- Includes:
- Emittr::Events
- Defined in:
- lib/hivent/emitter.rb
Constant Summary collapse
- WILDCARD =
:all
Instance Attribute Summary collapse
-
#events ⇒ Object
Returns the value of attribute events.
Instance Method Summary collapse
- #broadcast(payload) ⇒ Object
- #emit(name, *data) ⇒ Object
-
#initialize ⇒ Emitter
constructor
A new instance of Emitter.
Constructor Details
#initialize ⇒ Emitter
Returns a new instance of Emitter.
11 12 13 |
# File 'lib/hivent/emitter.rb', line 11 def initialize @events = [] end |
Instance Attribute Details
#events ⇒ Object
Returns the value of attribute events.
7 8 9 |
# File 'lib/hivent/emitter.rb', line 7 def events @events end |
Instance Method Details
#broadcast(payload) ⇒ Object
15 16 17 18 19 |
# File 'lib/hivent/emitter.rb', line 15 def broadcast(payload) emittable_event_names(payload.with_indifferent_access).each do |emittable_event_name| emit(emittable_event_name, payload) end end |
#emit(name, *data) ⇒ Object
21 22 23 |
# File 'lib/hivent/emitter.rb', line 21 def emit(name, *data) super(name.to_sym, *data) end |