class Gemstash::DB::Authorization

Sequel model for authorizations table.

Public Class Methods

insert_or_update(auth_key, permissions, name = nil) click to toggle source
# File lib/gemstash/db/authorization.rb, line 9
def self.insert_or_update(auth_key, permissions, name = nil)
  db.transaction do
    record = self[auth_key: auth_key]

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