Class: Lode::Tables::Dictionary

Inherits:
Abstract
  • Object
show all
Defined in:
lib/lode/tables/dictionary.rb

Overview

Provides an array-based table for dictionary or hash-like 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
# File 'lib/lode/tables/dictionary.rb', line 11

def upsert change, key: primary_key
  find(change[key], key:).either(
    -> existing { revise existing, change },
    proc { append change }
  )
end