class

Athena::Routing::Parameters

Inherits Reference < Object

A container representing parameters defined via ART::Route#defaults, or returned when matching a route. Allows the value to be of any type.

Constructors

new(parameters : self) : self
Source
new(hash : Hash(String, _))
Source

Instance methods

[](name : String) : String

Returns the value of the parameter with the provided name as a String.

Raises a KeyError if no parameter with that name exists.

Source
[]=(name : String, value : T) : Nil forall T

Sets a parameter with the provided name to value.

Source
[]?(name : String) : String | Nil

Returns the value of the parameter with the provided name as a String if it exists, otherwise nil.

Source
delete(name : String) : Nil

Removes the parameter with the provided name.

Source
empty?

Returns true if empty.

Source
get(name : String, type : T.class) : T forall T

Returns the value of the parameter with the provided name, casted to the provided type.

Raises a KeyError if no parameter with that name exists.

Source
get?(name : String, type : T.class) : T | Nil forall T

Returns the value of the parameter with the provided name casted to the provided type if it exists, otherwise nil.

Source
has_key?(name : String) : Bool

Returns true if a parameter with the provided name exists, otherwise false.

Source
to_h

Returns a Hash(String, String?) representation of these parameters. Values that are not String? are converted via #to_s.

Source