我使用YARD作为我的Ruby on Rails应用程序文档。我有一个简单的模型,看起来像这样:
# frozen_string_literal: true
# {Patient} is model responsible for storing patient personal informations.
#
# @!attribute id
# @return [UUID] ID of the {Patient} in UUID format.
#
# @!attribute name
# @return [String] Name of the {Patient}.
#
# @!attribute gender
# @return [String] Gender of the {Patient}.
#
# @!attribute date_of_birth
# @return [Date] Date of birth of the {Patient}.
#
# @!attribute created_at
# @return [DateTime] Time when {Patient} was created.
#
# @!attribute updated_at
# @return [DateTime] Time when {Patient} was updated.
class Patient < ApplicationRecord
# == Relationships ========================================================
belongs_to :organization
# == Validations ==========================================================
validates :name, presence: true
validates :date_of_birth, presence: true
validates :gender, inclusion: { in: Constants::GENDERS }
end
我如何向YARD记录我的关系和验证?我看到有宝石https://github.com/theodorton/yard-activerecord,但它没有更新6年。
1条答案
按热度按时间3df52oht1#
ruby gem annotate是一种基于数据库自动记录函数的方法