Class: Euston::EventStore::CommandMessage

Inherits:
Object
  • Object
show all
Includes:
Persistence::Mongodb::MongoCommandMessage
Defined in:
lib/euston-eventstore/command_message.rb,
lib/euston-eventstore/persistence/mongodb/mongo_command_message.rb

Overview

Represents a single element in a stream of commands.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Persistence::Mongodb::MongoCommandMessage

from_hash

Constructor Details

#initialize(arg = nil) ⇒ CommandMessage

Returns a new instance of CommandMessage.



6
7
8
9
10
11
12
13
# File 'lib/euston-eventstore/command_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 comman body.



23
24
25
# File 'lib/euston-eventstore/command_message.rb', line 23

def body
  @body
end

#headersObject (readonly)

Gets the metadata which provides additional, unstructured information about this command.



20
21
22
# File 'lib/euston-eventstore/command_message.rb', line 20

def headers
  @headers
end

Instance Method Details

#to_hashObject



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

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