Class: Synapse::Domain::EventMessage
- Defined in:
- lib/synapse/domain/message.rb
Overview
Represents the occurance of an event in the application that may be of some importance to another component of the application. It contains the relevant data for other components to act upon.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#timestamp ⇒ Time
readonly
The timestamp of when the event was reported.
Attributes inherited from Message
Class Method Summary collapse
-
.as_message(event) ⇒ EventMessage
Creates an event message using the given event object.
- .builder ⇒ Class
Instance Method Summary collapse
Methods inherited from Message
#and_metadata, build, #payload_type, #with_metadata
Constructor Details
#initialize(id, metadata, payload, timestamp) ⇒ undefined
16 17 18 19 |
# File 'lib/synapse/domain/message.rb', line 16 def initialize(id, , payload, ) super id, , payload @timestamp = end |
Instance Attribute Details
#timestamp ⇒ Time (readonly)
The timestamp of when the event was reported
9 10 11 |
# File 'lib/synapse/domain/message.rb', line 9 def @timestamp end |
Class Method Details
.as_message(event) ⇒ EventMessage
Creates an event message using the given event object
If the given object is an event message, it will be returned unchanged.
32 33 34 35 36 37 38 39 40 |
# File 'lib/synapse/domain/message.rb', line 32 def self.(event) unless event.is_a? EventMessage event = self.build do |builder| builder.payload = event end end event end |
.builder ⇒ Class
22 23 24 |
# File 'lib/synapse/domain/message.rb', line 22 def self.builder EventMessageBuilder end |