# frozen_string_literal: true
module ESM
class APIToken < ApplicationRecord
# =============================================================================
# INITIALIZE
# =============================================================================
# =============================================================================
# DATA STRUCTURE
# =============================================================================
attribute :token, :string
attribute :active, :boolean, default: true
attribute :comment, :string
attribute :created_at, :datetime
attribute :updated_at, :datetime
# =============================================================================
# ASSOCIATIONS
# =============================================================================
# =============================================================================
# VALIDATIONS
# =============================================================================
# =============================================================================
# CALLBACKS
# =============================================================================
before_save :create_token
# =============================================================================
# SCOPES
# =============================================================================
# =============================================================================
# CLASS METHODS
# =============================================================================
# =============================================================================
# INSTANCE METHODS
# =============================================================================
private
def create_token
self.token = SecureRandom.uuid.delete("-").upcase
end
end
end