The RBS generator for Active Record models focus on generating methods that are generated by Active Record. For example, it generates the following things.
- Classes which inherit
ActiveRecord::Base
- Generated methods by Active Record
- Column methods. e.g.
name
andname=
methods forname
column. - Relation methods. e.g.
users
andusers=
methods forhas_many :users
. - And so on.
- Column methods. e.g.
I designed it generates "valid" RBSs. "valid" means the generated RBSs pass rbs validate
only with rbs collection
.
So if you need to do something to pass rbs validate
, it's a bug. For example, if you see RBS::NoSuperclassFoundError
for the generated RBS, it is a bug.
RBS Rails focuses on generating "generated" methods. It means it doesn't generate methods that are defined by the user. For example:
class User < ApplicationRecord
# RBS Rails generates articles methods and so on
# becasue they are generated by Active Record.
has_many :articles
# RBS Rails does NOT generate full_name method
# because the user defines it.
def full_name
first_name + last_name
end
end
You can use rbs prototype rb
, rbs prototype runtime
and typeprof
commands to generate them.
TODO