class Riffer::Params::AnyOf
rbs_inline: enabled
Attributes
@rbs @name: Symbol
Public Class Methods
Source
# File lib/riffer/params/any_of.rb, line 11 def initialize(name) @name = name @variants = [] end
Public Instance Methods
Source
# File lib/riffer/params/any_of.rb, line 18 def variant(type = nil, description: nil, enum: nil, format: nil, &block) if type raise Riffer::ArgumentError, "variant takes a type or a block, not both" if block @variants << primitive(type, description, enum, format) elsif block if description || enum || format raise Riffer::ArgumentError, "description:, enum: and format: only apply to a primitive variant" end params = Riffer::Params.new params.instance_eval(&block) @variants << params else raise Riffer::ArgumentError, "variant requires a type or a block defining its properties" end end