Module: Euston::EventStore::Persistence::Mongodb::MongoSnapshot

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ Object



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

def from_hash(hash)
  return nil if hash.nil?

  id = hash['_id']

  Snapshot.new id['stream_id'],
               id['stream_revision'],
               hash['payload'].recursive__symbolize__keys!,
               hash['headers'].recursive__symbolize__keys!
end

Instance Method Details

#to_hashObject



21
22
23
24
25
26
27
# File 'lib/euston-eventstore/persistence/mongodb/mongo_snapshot.rb', line 21

def to_hash
  {
    :_id => { :stream_id => stream_id, :stream_revision => stream_revision },
    :headers => headers,
    :payload => payload.recursive_stringify_symbol_values!
  }
end