class Tapioca::Dsl::Compilers::ActiveModelValidationsConfirmation
~~~
end
def password_confirmation=(password_confirmation); end
sig { params(password_confirmation=: T.untyped).returns(T.untyped) }
def password_confirmation; end
sig { returns(T.untyped) }
def email_confirmation=(email_confirmation); end
sig { params(email_confirmation=: T.untyped).returns(T.untyped) }
def email_confirmation; end
sig { returns(T.untyped) }
class User
# typed: true
~~~rbi
this compiler will produce an RBI file with the following content:
~~~
end
validates :email, confirmation: true
validates_confirmation_of :password
include ActiveModel::Validations
class User
~~~rb
For example, with the following class:
classes that use [‘ActiveModel::Validates::Confirmation`](api.rubyonrails.org/classes/ActiveModel/Validations/HelperMethods.html#method-i-validates_confirmation_of).
`Tapioca::Dsl::Compilers::ActiveModelValidationsConfirmation` decorates RBI files for all
def decorate
def decorate confirmation_validators = constant.validators.grep(ActiveModel::Validations::ConfirmationValidator) return if confirmation_validators.empty? # Create a RBI definition for each class that includes Active::Model::Validations root.create_path(constant) do |klass| # Create RBI definitions for all the attributes that use confirmation validation confirmation_validators.each do |validator| validator.attributes.each do |attr_name| klass.create_method("#{attr_name}_confirmation", return_type: "T.untyped") klass.create_method( "#{attr_name}_confirmation=", parameters: [create_param("#{attr_name}_confirmation", type: "T.untyped")], return_type: "T.untyped", ) end end end end
def gather_constants
def gather_constants # Collect all the classes that include ActiveModel::Validations all_classes.select { |c| ActiveModel::Validations > c } end