Class: Tapioca::Compilers::Dsl::ActiveResource
- Extended by:
- T::Sig
- Defined in:
- lib/tapioca/compilers/dsl/active_resource.rb
Overview
Tapioca::Compilers::Dsl::ActiveResource decorates RBI files for subclasses of [ActiveResource::Base](github.com/rails/activeresource) which declare schema fields.
For example, with the following ActiveResource::Base subclass:
~~~rb class Post < ActiveResource::Base
schema do
integer 'id', 'month', 'year'
end
end ~~~
this generator will produce the RBI file post.rbi with the following content:
~~~rbi # post.rbi # typed: true class Post
sig { returns(Integer) }
def id; end
sig { params(id: Integer).returns(Integer) }
def id=(id); end
sig { returns(T::Boolean) }
def id?; end
sig { returns(Integer) }
def month; end
sig { params(month: Integer).returns(Integer) }
def month=(month); end
sig { returns(T::Boolean) }
def month?; end
sig { returns(Integer) }
def year; end
sig { params(year: Integer).returns(Integer) }
def year=(year); end
sig { returns(T::Boolean) }
def year?; end
end ~~~
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Tapioca::Compilers::Dsl::Base
Instance Method Details
#decorate(root, constant) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/tapioca/compilers/dsl/active_resource.rb', line 72 def decorate(root, constant) return if constant.schema.blank? root.path(constant) do |resource| constant.schema.each do |attribute, type| create_schema_methods(resource, attribute, type) end end end |
#gather_constants ⇒ Object
83 84 85 |
# File 'lib/tapioca/compilers/dsl/active_resource.rb', line 83 def gather_constants ::ActiveResource::Base.descendants end |