class Tapioca::Dsl::Compilers::ActiveRecordSecureToken
: [ConstantType = (singleton(ActiveRecord::Base) & Extensions::ActiveRecord)]
~~~
end
def regenerate_auth_token; end
sig { returns(T::Boolean) }
def regenerate_token; end
sig { returns(T::Boolean) }
class User
# typed: true
~~~rbi
this compiler will produce an RBI file with the following content:
~~~
end
has_secure_token :auth_token, length: 36
has_secure_token
class User < ActiveRecord::Base
~~~rb
For example, with the following class:
classes that use [‘ActiveRecord::SecureToken`](api.rubyonrails.org/classes/ActiveRecord/SecureToken/ClassMethods.html).
`Tapioca::Dsl::Compilers::ActiveModelSecurePassword` decorates RBI files for all
def decorate
@override
def decorate return if constant.__tapioca_secure_tokens.nil? root.create_path(constant) do |model| model.create_module(SecureTokensModuleName) do |mod| constant.__tapioca_secure_tokens.each do |attribute| mod.create_method( "regenerate_#{attribute}", return_type: "T::Boolean", ) end end model.create_include(SecureTokensModuleName) end end
def gather_constants
@override
def gather_constants descendants_of(::ActiveRecord::Base).reject(&:abstract_class?) end