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.crmarten/routing/reverser/mismatch.cr
Constructors
- .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.
- #prefix_default_locale=(prefix_default_locale : Bool)
- #prefix_default_locale? : Bool
- #prefix_locales=(prefix_locales : Bool)
- #prefix_locales? : Bool
-
#reverse(params : Nil | Hash(String | Symbol, Parameter::Types)) : String | Nil
Reverses the route for the given parameters.
Constructor Detail
Instance Method Detail
Combines the current reverser with another reverser.
The new reverser will have a combined name, path, and parameters.
Returns the path for interpolation for the current locale.
Reverses the route for the given parameters.
If the parameters do not match the expected parameters for the route, nil is returned.