Sha256: 2b25e8be879218a9938c135f113067b51728c6084c91285795e75a64b09f8160

Contents?: true

Size: 585 Bytes

Versions: 6

Compression:

Stored size: 585 Bytes

Contents

module PhobosDBCheckpoint
  class Event < ActiveRecord::Base
    include PhobosDBCheckpoint::EventHelper
    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

6 entries across 6 versions & 1 rubygems

Version Path
phobos_db_checkpoint-2.2.0 lib/phobos_db_checkpoint/event.rb
phobos_db_checkpoint-2.1.0 lib/phobos_db_checkpoint/event.rb
phobos_db_checkpoint-2.0.0 lib/phobos_db_checkpoint/event.rb
phobos_db_checkpoint-2.0.0.rc1 lib/phobos_db_checkpoint/event.rb
phobos_db_checkpoint-1.1.0 lib/phobos_db_checkpoint/event.rb
phobos_db_checkpoint-1.0.0 lib/phobos_db_checkpoint/event.rb