Sha256: 67a9c93dc5ab37295cee27b8b4ce8e221e0775348fd0b8ce444acf30ec209feb

Contents?: true

Size: 637 Bytes

Versions: 12

Compression:

Stored size: 637 Bytes

Contents

# frozen_string_literal: true

module Eventsimple
  module Outbox
    class Cursor < ApplicationRecord
      self.table_name = 'eventsimple_outbox_cursors'

      def self.fetch(event_klass, group_number)
        existing = find_by(event_klass: event_klass.to_s, group_number: group_number)
        existing ? existing.cursor : 0
      end

      def self.set(event_klass, group_number, cursor)
        upsert(
          {
            event_klass: event_klass.to_s,
            group_number: group_number,
            cursor: cursor,
          },
          unique_by: [:event_klass, :group_number],
        )
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
eventsimple-1.3.2 lib/eventsimple/outbox/models/cursor.rb
eventsimple-1.3.1 lib/eventsimple/outbox/models/cursor.rb
eventsimple-1.3.0 lib/eventsimple/outbox/models/cursor.rb
eventsimple-1.2.3 lib/eventsimple/outbox/models/cursor.rb
eventsimple-1.2.2 lib/eventsimple/outbox/models/cursor.rb
eventsimple-1.2.1 lib/eventsimple/outbox/models/cursor.rb
eventsimple-1.2.0 lib/eventsimple/outbox/models/cursor.rb
eventsimple-1.1.3 lib/eventsimple/outbox/models/cursor.rb
eventsimple-1.1.2 lib/eventsimple/outbox/models/cursor.rb
eventsimple-1.1.1 lib/eventsimple/outbox/models/cursor.rb
eventsimple-1.1.0 lib/eventsimple/outbox/models/cursor.rb
eventsimple-1.0.0 lib/eventsimple/outbox/models/cursor.rb