Class: InstantRecord::SyncMetadata

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/instant_record/sync_metadata.rb

Overview

Browser-local key/value store; holds the SSE cursor across reloads.

Class Method Summary collapse

Class Method Details

.get(key) ⇒ Object



7
8
9
# File 'lib/instant_record/sync_metadata.rb', line 7

def self.get(key)
  find_by(key: key)&.value
end

.set(key, value) ⇒ Object



11
12
13
14
# File 'lib/instant_record/sync_metadata.rb', line 11

def self.set(key, value)
  record = find_or_initialize_by(key: key)
  record.update!(value: value.to_s)
end