Class: Euston::EventStore::EventMessage
- Inherits:
-
Object
- Object
- Euston::EventStore::EventMessage
- Includes:
- Persistence::Mongodb::MongoEventMessage
- Defined in:
- lib/euston-eventstore/event_message.rb,
lib/euston-eventstore/persistence/mongodb/mongo_event_message.rb
Overview
Represents a single element in a stream of events.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Gets or sets the actual event message body.
-
#headers ⇒ Object
readonly
Gets the metadata which provides additional, unstructured information about this message.
Instance Method Summary collapse
-
#initialize(arg = nil) ⇒ EventMessage
constructor
A new instance of EventMessage.
- #to_hash ⇒ Object
Methods included from Persistence::Mongodb::MongoEventMessage
Constructor Details
#initialize(arg = nil) ⇒ EventMessage
Returns a new instance of EventMessage.
6 7 8 9 10 11 12 13 |
# File 'lib/euston-eventstore/event_message.rb', line 6 def initialize(arg = nil) if arg.is_a?(Hash) && (arg.keys & ['body','headers']).size == 2 @body, @headers = arg.values_at('body','headers') else @headers = {} @body = arg end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Gets or sets the actual event message body.
23 24 25 |
# File 'lib/euston-eventstore/event_message.rb', line 23 def body @body end |
#headers ⇒ Object (readonly)
Gets the metadata which provides additional, unstructured information about this message.
20 21 22 |
# File 'lib/euston-eventstore/event_message.rb', line 20 def headers @headers end |
Instance Method Details
#to_hash ⇒ Object
15 16 17 |
# File 'lib/euston-eventstore/event_message.rb', line 15 def to_hash {:headers=>@headers,:body=>@body} end |