class
Athena::Routing::Parameters
- Athena::Routing::Parameters
- Reference
- Object
Overview
A container representing parameters defined via ART::Route#defaults, or returned when matching a route.
Allows the value to be of any type.
Defined in:
parameters.crConstructors
Instance Method Summary
-
#[](name : String) : String
Returns the value of the parameter with the provided name as a
String. -
#[]=(name : String, value : T) : Nil forall T
Sets a parameter with the provided name to value.
-
#[]?(name : String) : String | Nil
Returns the value of the parameter with the provided name as a
Stringif it exists, otherwisenil. -
#delete(name : String) : Nil
Removes the parameter with the provided name.
-
#empty? : Bool
Returns
trueif empty. -
#get(name : String, type : T.class) : T forall T
Returns the value of the parameter with the provided name, casted to the provided type.
-
#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. -
#has_key?(name : String) : Bool
Returns
trueif a parameter with the provided name exists, otherwisefalse. -
#to_h : Hash(String, String | Nil)
Returns a
Hash(String, String?)representation of these parameters.
Constructor Detail
Instance Method Detail
Returns the value of the parameter with the provided name as a String.
Raises a KeyError if no parameter with that name exists.
Sets a parameter with the provided name to value.
Returns the value of the parameter with the provided name as a String if it exists, otherwise nil.
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.
Returns the value of the parameter with the provided name casted to the provided type if it exists, otherwise nil.
Returns true if a parameter with the provided name exists, otherwise false.
Returns a Hash(String, String?) representation of these parameters.
Values that are not String? are converted via #to_s.