compiler_activemodelattributes.md

August 6, 2025 ยท View on GitHub

ActiveModelAttributes

Tapioca::Dsl::Compilers::ActiveModelAttributes decorates RBI files for all classes that use ActiveModel::Attributes.

For example, with the following class:

class Shop
  include ActiveModel::Attributes

  attribute :name, :string
end

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

# typed: true

class Shop
  include GeneratedAttributeMethods

  module GeneratedAttributeMethods
    sig { returns(T.nilable(::String)) }
    def name; end

    sig { params(name: T.nilable(::String)).returns(T.nilable(::String)) }
    def name=(name); end
  end

end