class Synapse::EventSourcing::IntervalSnapshotPolicy
Snapshot policy that takes a snapshot if the number of events committed in an aggregate since the last snapshot goes over the configured threshold
Public Class Methods
new(threshold)
click to toggle source
@param [Integer] threshold @return [undefined]
# File lib/synapse/event_sourcing/snapshot/policy.rb, line 19 def initialize(threshold) @threshold = threshold end
Public Instance Methods
should_snapshot?(aggregate)
click to toggle source
@param [AggregateRoot] aggregate @return [Boolean]
# File lib/synapse/event_sourcing/snapshot/policy.rb, line 25 def should_snapshot?(aggregate) (aggregate.version - (aggregate.initial_version or 0)) >= @threshold end