class Tapioca::Dsl::Compilers::ActiveResource

~~~
end
def year?; end
sig { returns(T::Boolean) }
def year=(year); end
sig { params(year: Integer).returns(Integer) }
def year; end
sig { returns(Integer) }
def month?; end
sig { returns(T::Boolean) }
def month=(month); end
sig { params(month: Integer).returns(Integer) }
def month; end
sig { returns(Integer) }
def id?; end
sig { returns(T::Boolean) }
def id=(id); end
sig { params(id: Integer).returns(Integer) }
def id; end
sig { returns(Integer) }
class Post
# typed: true
# post.rbi
~~~rbi
this compiler will produce the RBI file ‘post.rbi` with the following content:
~~~
end
end
integer ’id’, ‘month’, ‘year’
schema do
class Post < ActiveResource::Base
~~~rb
For example, with the following ‘ActiveResource::Base` subclass:
`schema` fields.<br>(github.com/rails/activeresource) which declare
`Tapioca::Dsl::Compilers::ActiveResource` decorates RBI files for subclasses of

def create_schema_methods(klass, attribute, type)

def create_schema_methods(klass, attribute, type)
  return_type = type_for(type.to_sym)
  klass.create_method(attribute, return_type: return_type)
  klass.create_method("#{attribute}?", return_type: "T::Boolean")
  klass.create_method(
    "#{attribute}=",
    parameters: [
      create_param("value", type: return_type),
    ],
    return_type: return_type,
  )
end

def decorate

def decorate
  return if constant.schema.blank?
  root.create_path(constant) do |resource|
    constant.schema.each do |attribute, type|
      create_schema_methods(resource, attribute, type)
    end
  end
end

def gather_constants

def gather_constants
  descendants_of(::ActiveResource::Base)
end

def type_for(attr_type)

def type_for(attr_type)
  TYPES.fetch(attr_type, "T.untyped")
end