NAME
Gears::Router::Pattern - Base pattern matching and building
SYNOPSIS
use Gears::Router::Pattern;
my $pattern = Gears::Router::Pattern->new(
location => $location,
);
# Compare a path against the pattern
my $match_data = $pattern->compare('/user/123');
# Build a URL from the pattern
my $url = $pattern->build(id => 123);
DESCRIPTION
Gears::Router::Pattern is the base class for pattern matching and URL building. It holds a reference to a location and delegates the pattern string and bridge status to it. Subclasses implement the actual matching and building logic.
This class is abstract, it requires subclassing. Take a look at Gears::Router::Pattern::Match for the simplest example of a subclass.
INTERFACE
Attributes
location
A weak reference to the Gears::Router::Location object that owns this pattern.
Required in constructor
Methods
new
$object = $class->new(%args)
A standard Mooish constructor. Consult "Attributes" section to learn what keys can key passed in %args.
compare
$match_data = $pattern->compare($request_path)
Compares the given request path string against this pattern. Returns an array reference with matched data if successful, or undef if the path doesn't match. This method must be implemented by subclasses.
build
$url = $pattern->build(%params)
Builds a URL string from this pattern by substituting placeholders with the provided parameters. This method must be implemented by subclasses.
pattern
$str = $pattern->pattern()
Returns the pattern string from the associated location. This method is delegated to the location attribute.
is_bridge
$bool = $pattern->is_bridge()
Returns true if the associated location has child locations. This method is delegated to the location attribute.