Class: Euston::EventStore::EventMessage

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from Persistence::Mongodb::MongoEventMessage

from_hash

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

#bodyObject (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

#headersObject (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_hashObject



15
16
17
# File 'lib/euston-eventstore/event_message.rb', line 15

def to_hash
  {:headers=>@headers,:body=>@body}
end