No plan yet, but worth considering. class Student < ApplicationRecord include Enumerable # including Enumerable[Student] # @type method classes: () -> ActiveRecord::Relation[Student] # @type method class_ids: () -> ActiveRecord::IDRelation has_many :classes # @type (University, classes: Array[ClassDefinition], requirements: Requirement, credits: Integer) -> Ar def minimum_classes_to_graduations(univ, classes:, requirements:, credits:) ... end end