class Slimer::ApiKey
A Sequel::Model wrapper around the api_keys table
Public Class Methods
generate(name)
click to toggle source
# File lib/slimer/api_key.rb, line 8 def self.generate(name) new_token = loop do generated_token = SecureRandom.urlsafe_base64 break generated_token unless token_exists?(generated_token) end create name: name, token: new_token end
token_exists?(token)
click to toggle source
# File lib/slimer/api_key.rb, line 17 def self.token_exists?(token) ApiKey.where(token: token).count.positive? end