Class: Gemstash::DB::Authorization

Inherits:
Sequel::Model
  • Object
show all
Defined in:
lib/gemstash/db/authorization.rb

Overview

Sequel model for authorizations table.

Class Method Summary collapse

Class Method Details

.insert_or_update(auth_key, permissions) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/gemstash/db/authorization.rb', line 7

def self.insert_or_update(auth_key, permissions)
  db.transaction do
    record = self[auth_key: auth_key]

    if record
      record.update(permissions: permissions)
    else
      create(auth_key: auth_key, permissions: permissions)
    end
  end
end