Class: Lode::Tables::Hash

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

Overview

Provides an array-based table for hash 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/hash.rb', line 11

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