Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 1.11 KB

compiler_activesupportcurrentattributes.md

File metadata and controls

55 lines (41 loc) · 1.11 KB

ActiveSupportCurrentAttributes

Tapioca::Dsl::Compilers::ActiveSupportCurrentAttributes decorates RBI files for all subclasses of ActiveSupport::CurrentAttributes.

For example, with the following singleton class

class Current < ActiveSupport::CurrentAttributes
  extend T::Sig

  attribute :account

  def helper
    # ...
  end

  sig { params(user_id: Integer).void }
  def authenticate(user_id)
    # ...
  end
end

this compiler will produce an RBI file with the following content:

# typed: true

class Current
  include GeneratedAttributeMethods

  class << self
    sig { returns(T.untyped) }
    def account; end

    sig { params(account: T.untyped).returns(T.untyped) }
    def account=(account); end

    sig { params(user_id: Integer).void }
    def authenticate(user_id); end

    sig { returns(T.untyped) }
    def helper; end
  end

  module GeneratedAttributeMethods
    sig { returns(T.untyped) }
    def account; end

    sig { params(account: T.untyped).returns(T.untyped) }
    def account=(account); end
  end
end