Sha256: adfa96d010dbe027be525a7b86e5922e7fb851e4dc205bf7df8963363a6a4e51

Contents?: true

Size: 427 Bytes

Versions: 5

Compression:

Stored size: 427 Bytes

Contents

module Sandthorn
  module AggregateRootSnapshot
    attr_reader :aggregate_snapshot

    def snapshot
      aggregate_snapshot!
      save_snapshot
      self
    end

    def aggregate_snapshot!
      if @aggregate_events.count > 0
        raise Errors::SnapshotError,
          "Can't take snapshot on object with unsaved events"
      end
    end

    def save_snapshot
      Sandthorn.save_snapshot(self)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sandthorn-1.1.0 lib/sandthorn/aggregate_root_snapshot.rb
sandthorn-1.0.0 lib/sandthorn/aggregate_root_snapshot.rb
sandthorn-0.13.0 lib/sandthorn/aggregate_root_snapshot.rb
sandthorn-0.12.0 lib/sandthorn/aggregate_root_snapshot.rb
sandthorn-0.11.0 lib/sandthorn/aggregate_root_snapshot.rb