lib/emittance/emitter.rb in emittance-1.1.0 vs lib/emittance/emitter.rb in emittance-2.0.0.pre.1

- old
+ new

@@ -56,32 +56,29 @@ # @param identifier [Symbol, Emittance::Event] either an explicit Event object or the identifier that can be # parsed into an Event object. # @param payload [*] any additional information that might be helpful for an event's handler to have. Can be # standardized on a per-event basis by pre-defining the class associated with the identifier and validating # the payload. See {Emittance::Event} for more details. - # @param broker [Symbol] the identifier for the broker you wish to handle the event. Requires additional gems - # if not using the default. # # @return the payload def emit(identifier, payload: nil) now = Time.now event_klass = _event_klass_for identifier - event = event_klass.new(self, now, payload) + event = event_klass.new(self, now, payload).tap { |the_event| the_event.topic = identifier } _send_to_broker event payload end # If you don't know the specific identifier whose event you want to emit, you can send it a bunch of stuff and # +Emitter+ will automatically generate an +Event+ class for you. # # @param identifiers [*] anything that can be used to generate an +Event+ class. # @param payload (@see #emit) - # @param broker (@see #emit) def emit_with_dynamic_identifier(*identifiers, payload:) now = Time.now event_klass = _event_klass_for(*identifiers) - event = event_klass.new(self, now, payload) + event = event_klass.new(self, now, payload).tap { |the_event| the_event.topic = identifiers.join('.') } _send_to_broker event payload end