Module: IndexUtil::IndexMetadata

Defined in:
lib/index_util/index_metadata.rb

Class Method Summary collapse

Class Method Details

.get(db, key) ⇒ Object



9
10
11
# File 'lib/index_util/index_metadata.rb', line 9

def get(db, key)
  db[:index_metadata].where(key: key.to_s).get(:value)
end

.set(db, key, value) ⇒ Object



13
14
15
16
17
# File 'lib/index_util/index_metadata.rb', line 13

def set(db, key, value)
  now = timestamp
  row = { key: key.to_s, value: value.to_s, updated_at: now }
  db[:index_metadata].insert_conflict(target: :key, update: { value: row[:value], updated_at: now }).insert(row)
end

.timestampObject



19
20
21
# File 'lib/index_util/index_metadata.rb', line 19

def timestamp
  Time.now.utc.iso8601
end