struct Athena::Framework::Controller::ParameterMetadata(T)
inherits Struct
#
Represents a controller action parameter. Stores metadata associated with it, such as its name, type, and default value if any.
Methods#
#annotation_configurations : ADI::AnnotationConfigurations
#
Returns annotation configurations registered via ADI.configuration_annotation
and applied to this parameter.
These configurations could then be accessed within ATHR::Interface
s and/or ATH::Listeners
s.
#default_value : T
#
Returns the default value for this parameter, raising an exception if it does not have one.
#default_value? : T | ::Nil
#
Returns the default value for this parameter, or nil
if it does not have one.
#first_type_of(klass : Type.class) forall Type
#
Returns the metaclass of the first matching type variable that is an #instance_of?
the provided klass, or nil
if none match.
If this the #type
is union, this would be the first viable type.
ATH::Controller::ParameterMetadata(Int32).new("foo").first_type_of(Int32) # => Int32.class
ATH::Controller::ParameterMetadata(String | Int32 | Bool).new("foo").first_type_of(Int32) # => Int32.class
ATH::Controller::ParameterMetadata(String | Int8 | Float64 | Int64).new("foo").first_type_of(Number) # => Float64.class
ATH::Controller::ParameterMetadata(String | Int32 | Bool).new("foo").first_type_of(Float64) # => nil
#has_default? : Bool
#
Returns true
if this parameter has a default value set, otherwise false
.
#instance_of?(klass : Type.class) : Bool forall Type
#
Returns true
if this parameter's #type
includes the provided klass.
ATH::Controller::ParameterMetadata(Int32).new("foo").instance_of?(Int32) # => true
ATH::Controller::ParameterMetadata(Int32 | Bool).new("foo").instance_of?(Bool) # => true
ATH::Controller::ParameterMetadata(Int32).new("foo").instance_of?(String) # => false