class Marten::Routing::Reverser

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

Constructors

Instance Method Summary

Constructor Detail

def self.new(name : String, path_for_interpolation : String, parameters : Hash(String, Marten::Routing::Parameter::Base) = {} of String => Parameter::Base) #

[View source]
def self.new(name : String, path_for_interpolations : Hash(String | Nil, String), parameters : Hash(String, Marten::Routing::Parameter::Base) = {} of String => Parameter::Base) #

[View source]

Instance Method Detail

def combine(other : Reverser) : Reverser #

Combines the current reverser with another reverser.

The new reverser will have a combined name, path, and parameters.


[View source]
def name : String #

[View source]
def parameters : Hash(String, Marten::Routing::Parameter::Base) #

[View source]
def path_for_interpolation : String #

Returns the path for interpolation for the current locale.


[View source]
def reverse(params : Nil | Hash(String | Symbol, Parameter::Types)) : Nil | String #

Reverses the route for the given parameters.

If the parameters do not match the expected parameters for the route, nil is returned.


[View source]