Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 1.27 KB

DESIGN.md

File metadata and controls

36 lines (27 loc) · 1.27 KB

RBS Generator for Active Record models

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 and name= methods for name column.
    • Relation methods. e.g. users and users= methods for has_many :users.
    • And so on.

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.

RBS Generator for the path helper

TODO