Class: Eventsimple::Outbox::Cursor

Inherits:
Object
  • Object
show all
Defined in:
lib/eventsimple/outbox/models/cursor.rb

Class Method Summary collapse

Class Method Details

.fetch(identifier) ⇒ Object



8
9
10
11
# File 'lib/eventsimple/outbox/models/cursor.rb', line 8

def self.fetch(identifier)
  existing = find_by(identifier: identifier)
  existing ? existing.cursor : 0
end

.set(identifier, cursor) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/eventsimple/outbox/models/cursor.rb', line 13

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