class Tapioca::Dsl::Compilers::ActiveSupportCurrentAttributes

~~~
end
end
def account=(account); end
sig { params(account: T.untyped).returns(T.untyped) }
def account; end
sig { returns(T.untyped) }
module GeneratedAttributeMethods
end
def helper; end
sig { returns(T.untyped) }
def authenticate(user_id); end
sig { params(user_id: Integer).void }
def account=(account); end
sig { params(account: T.untyped).returns(T.untyped) }
def account; end
sig { returns(T.untyped) }
class << self
include GeneratedAttributeMethods
class Current
# typed: true
~~~rbi
this compiler will produce an RBI file with the following content:
~~~
end
end
# …
def authenticate(user_id)
sig { params(user_id: Integer).void }
end
# …
def helper
attribute :account
extend T::Sig
class Current < ActiveSupport::CurrentAttributes
~~~rb
For example, with the following singleton class<br><br>(api.rubyonrails.org/classes/ActiveSupport/CurrentAttributes.html).
subclasses of
`Tapioca::Dsl::Compilers::ActiveSupportCurrentAttributes` decorates RBI files for all

def decorate

def decorate
  dynamic_methods = dynamic_methods_of_constant
  instance_methods = instance_methods_of_constant - dynamic_methods
  return if dynamic_methods.empty? && instance_methods.empty?
  root.create_path(constant) do |current_attributes|
    current_attributes_methods_name = "GeneratedAttributeMethods"
    current_attributes.create_module(current_attributes_methods_name) do |generated_attribute_methods|
      dynamic_methods.each do |method|
        method = method.to_s
        # We want to generate each method both on the class
        generate_method(current_attributes, method, class_method: true)
        # and on the instance
        generate_method(generated_attribute_methods, method, class_method: false)
      end
      instance_methods.each do |method|
        # instance methods are only elevated to class methods
        # no need to add separate instance methods for them
        method = constant.instance_method(method)
        create_method_from_def(current_attributes, method, class_method: true)
      end
    end
    current_attributes.create_include(current_attributes_methods_name)
  end
end

def dynamic_methods_of_constant

def dynamic_methods_of_constant
  constant.instance_variable_get(:@generated_attribute_methods)&.instance_methods(false) || []
end

def gather_constants

def gather_constants
  descendants_of(::ActiveSupport::CurrentAttributes)
end

def generate_method(klass, method, class_method:)

def generate_method(klass, method, class_method:)
  method_def = if class_method
    constant.method(method)
  else
    constant.instance_method(method)
  end
  create_method_from_def(klass, method_def, class_method: class_method)
end

def instance_methods_of_constant

def instance_methods_of_constant
  constant.instance_methods(false)
end