class Marten::Routing::Reverser
- Marten::Routing::Reverser
- Reference
- Object
Overview
Represents a route reverser.
A route reverser allows to perform URL / route lookups for a given route. Such routes can optionally expect
parameters and such parameters are handled accordingly when the #reverse
method is called. The main
Marten::Routing::Map#reverse
method makes use of reverser objects internally in order to perform routes lookups.
Defined in:
marten/routing/reverser.crConstructors
- .new(name : String, path_for_interpolation : String, parameters : Hash(String, Marten::Routing::Parameter::Base) = {} of String => Parameter::Base)
- .new(name : String, path_for_interpolations : Hash(String | Nil, String), parameters : Hash(String, Marten::Routing::Parameter::Base) = {} of String => Parameter::Base)
Instance Method Summary
-
#combine(other : Reverser) : Reverser
Combines the current reverser with another reverser.
- #name : String
- #parameters : Hash(String, Marten::Routing::Parameter::Base)
-
#path_for_interpolation : String
Returns the path for interpolation for the current locale.
-
#reverse(params : Nil | Hash(String | Symbol, Parameter::Types)) : Nil | String
Reverses the route for the given parameters.
Constructor Detail
def self.new(name : String, path_for_interpolation : String, parameters : Hash(String, Marten::Routing::Parameter::Base) = {} of String => Parameter::Base)
#
def self.new(name : String, path_for_interpolations : Hash(String | Nil, String), parameters : Hash(String, Marten::Routing::Parameter::Base) = {} of String => Parameter::Base)
#
Instance Method Detail
Combines the current reverser with another reverser.
The new reverser will have a combined name, path, and parameters.
Reverses the route for the given parameters.
If the parameters do not match the expected parameters for the route, nil
is returned.