Skip to content

struct Athena::Framework::Arguments::ArgumentMetadata(T)
inherits Struct #

Represents a controller action argument. Stores metadata associated with it, such as its name, type, and default value if any.

Methods#

#default_value : T#

Returns the default value for this argument, raising an exception if it does not have one.

View source

#default_value? : T | ::Nil#

Returns the default value for this argument, or nil if it does not have one.

View source

#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::Arguments::ArgumentMetadata(Int32).new("foo").first_type_of(Int32)                            # => Int32.class
ATH::Arguments::ArgumentMetadata(String | Int32 | Bool).new("foo").first_type_of(Int32)            # => Int32.class
ATH::Arguments::ArgumentMetadata(String | Int8 | Float64 | Int64).new("foo").first_type_of(Number) # => Float64.class
ATH::Arguments::ArgumentMetadata(String | Int32 | Bool).new("foo").first_type_of(Float64)          # => nil
View source

#has_default? : Bool#

Returns true if this argument has a default value set, otherwise false.

View source

#instance_of?(klass : Type.class) : Bool forall Type#

Returns true if this argument's #type includes the provided klass.

ATH::Arguments::ArgumentMetadata(Int32).new("foo").instance_of?(Int32)       # => true
ATH::Arguments::ArgumentMetadata(Int32 | Bool).new("foo").instance_of?(Bool) # => true
ATH::Arguments::ArgumentMetadata(Int32).new("foo").instance_of?(String)      # => false
View source

#name : String#

Returns the name of the argument.

View source

#nilable? : Bool#

If nil is a valid argument for the argument.

View source

#type : T.class#

The type of the parameter, i.e. what its type restriction is.

View source