Ricardo SIGNES > Router-Dumb-0.003 > Router::Dumb::Route

Download:
Router-Dumb-0.003.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.003   Source   Latest Release: Router-Dumb-0.005

NAME ^

Router::Dumb::Route - just one dumb route for use in a big dumb router

VERSION ^

version 0.003

OVERVIEW ^

Router::Dumb::Route objects represent paths that a Router::Dumb object can route to. They are usually created by calling the add_route method on a router.

ATTRIBUTES ^

target

The route's target is a string that can be used, for example, to give a file path or URL for the resource to which the user should be directed. Its meaning is left up to Router::Dumb's user.

parts

The parts attribute is an arrayref of strings that make up the route.

constraints

The constraints attribute holds a hashref of Moose type constraints objects, up to one for each placeholder.

METHODS ^

parts

This method returns a list of the contents of the parts attribute.

part_count

get_part

  my $part = $route->get_part( $n );

This returns the string located at position $n in the parts array.

path

This returns the /-joined list of path parts, or the empty string if parts is empty.

normalized_path

This method behaves like path, but placeholder parts are replaced with numbers so that, for example, instead of returning foo/:bar/baz/:quux we would return foo/:1/baz/:2. This normalization is used to prevent route collision.

is_slurpy

This method returns true if the path ends in the slurpy *.

has_params

This method returns true if any of the route's path parts is a placeholder (i.e., starts with a colon).

constraint_names

This method returns a list of all the placeholders for which a constraint is registered.

constraint_for

  my $tc = $route->constraint_for( $placeholder_name );

check

  my $match_or_undef = $route->check( $str );

This is the method used by the router to see if each route will accept the string. If it matches, it returns a match object. Otherwise, it returns false.

AUTHOR ^

Ricardo Signes <rjbs@cpan.org>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2012 by Ricardo Signes.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: