Class: Textus::Infra::Store::CursorStore

Inherits:
Base
  • Object
show all
Defined in:
lib/textus/infra/store/cursor_store.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Textus::Infra::Store::Base

Instance Method Details

#get(role) ⇒ Object



5
6
7
# File 'lib/textus/infra/store/cursor_store.rb', line 5

def get(role)
  result(table(:cursors).where(role:).first) || { role:, seq: 0 }
end

#get_loop(role) ⇒ Object



15
16
17
# File 'lib/textus/infra/store/cursor_store.rb', line 15

def get_loop(role)
  result(table(:loop_positions).where(role:).first) || { role:, index: 0 }
end

#set(role, seq) ⇒ Object



9
10
11
12
13
# File 'lib/textus/infra/store/cursor_store.rb', line 9

def set(role, seq)
  table(:cursors).insert_conflict(
    update: { seq:, updated_at: Time.now.utc },
  ).insert(role:, seq:, updated_at: Time.now.utc)
end

#set_loop(role, index) ⇒ Object



19
20
21
22
23
# File 'lib/textus/infra/store/cursor_store.rb', line 19

def set_loop(role, index)
  table(:loop_positions).insert_conflict(
    update: { index:, updated_at: Time.now.utc },
  ).insert(role:, index:, updated_at: Time.now.utc)
end