使用YARD记录Ruby on Rails模型

0aydgbwb  于 2023-05-17  发布在  Ruby
关注(0)|答案(1)|浏览(69)

我使用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年。

相关问题