Module: RailsSimpleEventSourcing::Events
- Extended by:
- ActiveSupport::Concern
- Includes:
- ReadOnly
- Defined in:
- app/models/concerns/rails_simple_event_sourcing/events.rb
Instance Method Summary collapse
Instance Method Details
#create_snapshot! ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/concerns/rails_simple_event_sourcing/events.rb', line 13 def create_snapshot! latest_event = events.order(version: :desc).first return unless latest_event RailsSimpleEventSourcing::Snapshot.create_or_update!( aggregate_type: self.class.name, aggregate_id: id, state: attributes, version: latest_event.version, schema_fingerprint: RailsSimpleEventSourcing::Snapshot.fingerprint_for(self.class) ) end |