Adds types

This commit is contained in:
2026-03-29 02:37:49 -04:00
parent 63276ef8ca
commit 323484a33a
44 changed files with 1273 additions and 121 deletions

View File

@@ -1,4 +1,8 @@
# typed: true
class ApiToken < ApplicationRecord
extend T::Sig
belongs_to :user
# Validations
@@ -11,16 +15,19 @@ class ApiToken < ApplicationRecord
scope :active, -> { where("expires_at IS NULL OR expires_at > ?", Time.current) }
# Instance methods
sig { returns(T::Boolean) }
def expired?
expires_at.present? && expires_at < Time.current
end
sig { void }
def touch_last_used!
update_column(:last_used_at, Time.current)
end
private
sig { void }
def generate_token
self.token ||= SecureRandom.urlsafe_base64(32)
end