Class: Hivent::Emitter

Inherits:
Object
  • Object
show all
Includes:
Emittr::Events
Defined in:
lib/hivent/emitter.rb

Constant Summary collapse

WILDCARD =
:all

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEmitter

Returns a new instance of Emitter.



11
12
13
# File 'lib/hivent/emitter.rb', line 11

def initialize
  @events = []
end

Instance Attribute Details

#eventsObject

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