Module: Euston::EventStore::Persistence::Mongodb::MongoEventMessage

Extended by:
ActiveSupport::Concern
Included in:
EventMessage
Defined in:
lib/euston-eventstore/persistence/mongodb/mongo_event_message.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/euston-eventstore/persistence/mongodb/mongo_event_message.rb', line 9

def from_hash(hash)
  hash.recursive_symbolize_keys!

  message = EventMessage.new hash[:body]
  message.instance_variable_set :@headers, hash[:headers]
  message
end

Instance Method Details

#to_hashObject



18
19
20
21
22
23
# File 'lib/euston-eventstore/persistence/mongodb/mongo_event_message.rb', line 18

def to_hash
  {
    :headers  => headers,
    :body     => body.to_hash.recursive_stringify_symbol_values!
  }
end