2023-12-28 11:45:18 -08:00
|
|
|
# typed: strict
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-10-14 10:50:57 -07:00
|
|
|
# This module provides methods to define specialized attributes.
|
|
|
|
# Method stubs are generated by the {Tapioca::Compilers::Attrables} compiler.
|
|
|
|
# @note The compiler is fragile, and must be updated if the filename changes, if methods are added or removed,
|
|
|
|
# or if a method's arity changes.
|
2023-12-28 11:45:18 -08:00
|
|
|
module Attrable
|
2024-10-06 09:25:57 -07:00
|
|
|
extend T::Helpers
|
|
|
|
|
|
|
|
requires_ancestor { Module }
|
|
|
|
|
2023-12-28 11:45:18 -08:00
|
|
|
sig { params(attrs: Symbol).void }
|
|
|
|
def attr_predicate(*attrs)
|
|
|
|
attrs.each do |attr|
|
|
|
|
define_method attr do
|
|
|
|
instance_variable_get("@#{attr.to_s.sub(/\?$/, "")}") == true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|