Class: Lode::Tables::Value

Inherits:
Abstract show all
Defined in:
lib/lode/tables/value.rb

Overview

Provides an array-based table for value objects.

Instance Method Summary collapse

Methods inherited from Abstract

#all, #create, #delete, #find, #initialize, #primary_key, #update

Constructor Details

This class inherits a constructor from Lode::Tables::Abstract

Instance Method Details

#upsert(change, key: primary_key) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/lode/tables/value.rb', line 11

def upsert change, key: primary_key
  record = record_for change

  find(primary_id(record, key:)).either(
    -> existing { revise existing, record },
    proc { append record }
  )
end