class Athena::Routing::Parameters

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.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(parameters : self) : self #

[View source]
def self.new(hash : Hash(String, _)) #

[View source]
def self.new #

[View source]

Instance Method Detail

def [](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.


[View source]
def []=(name : String, value : T) : Nil forall T #

Sets a parameter with the provided name to value.


[View source]
def []?(name : String) : String | Nil #

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


[View source]
def delete(name : String) : Nil #

Removes the parameter with the provided name.


[View source]
def empty? : Bool #

Returns true if empty.


[View source]
def 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.


[View source]
def 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.


[View source]
def has_key?(name : String) : Bool #

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


[View source]
def to_h : Hash(String, String | Nil) #

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


[View source]