Class: Masks::Rails::Key

Inherits:
ApplicationRecord show all
Includes:
Scoped
Defined in:
app/models/masks/rails/key.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Scoped

#role?, #role_records, #roles, #scope?

Class Method Details

.sha(secret) ⇒ Object



11
12
13
# File 'app/models/masks/rails/key.rb', line 11

def sha(secret)
  Digest::SHA512.hexdigest(secret)
end

Instance Method Details

#nicknameObject Also known as: slug



30
31
32
# File 'app/models/masks/rails/key.rb', line 30

def nickname
  [name.parameterize, sha.slice(0...32)].join("-")
end

#roles_for(_record, **_opts) ⇒ Object



44
45
46
# File 'app/models/masks/rails/key.rb', line 44

def roles_for(_record, **_opts)
  []
end

#scopesObject



36
37
38
39
40
41
42
# File 'app/models/masks/rails/key.rb', line 36

def scopes
  value = self[:scopes]

  return [] unless value

  value & (actor&.scopes || [])
end