Sha256: 73c68820930aa93ab74ebe3a624342bf237f9e1139346e30482913feedaaf5ce

Contents?: true

Size: 541 Bytes

Versions: 3

Compression:

Stored size: 541 Bytes

Contents

module PhobosDBCheckpoint
  class Event < ActiveRecord::Base
    after_initialize :assign_checksum

    def exists?
      Event.where(topic: topic, group_id: group_id, checksum: checksum).exists?
    end

    def acknowledge!(ack)
      self.entity_id = ack.entity_id
      self.event_time = ack.event_time
      self.event_type = ack.event_type
      self.event_version = ack.event_version
      save!
    end

    private

    def assign_checksum
      self.checksum ||= Digest::MD5.hexdigest(payload.to_json) if payload
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
phobos_db_checkpoint-0.2.0 lib/phobos_db_checkpoint/event.rb
phobos_db_checkpoint-0.1.1 lib/phobos_db_checkpoint/event.rb
phobos_db_checkpoint-0.1.0 lib/phobos_db_checkpoint/event.rb