Skip to content

Commit

Permalink
added example
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 30, 2011
1 parent 32b1144 commit 735d4ab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions lib/Mojolicious/Routes/Match.pm
Expand Up @@ -234,8 +234,19 @@ Mojolicious::Routes::Match - Routes Visitor
=head1 SYNOPSIS
use Mojolicious::Routes;
use Mojolicious::Routes::Match;
# Routes
my $r = Mojolicious::Routes->new;
$r->route('/foo')->to(action => 'foo');
$r->route('/bar')->to(action => 'bar');
# Match
my $m = Mojolicious::Routes::Match->new(GET => '/bar');
$m->match($r);
print $m->captures->{action};
=head1 DESCRIPTION
L<Mojolicious::Routes::Match> is a visitor for L<Mojolicious::Routes>
Expand Down
4 changes: 2 additions & 2 deletions t/mojolicious/routes.t
Expand Up @@ -363,7 +363,7 @@ is $m->stack->[0]->{action}, 'hello_json', 'right value';
is $m->stack->[0]->{format}, 'json', 'right value';
is $m->path_for, '/format2.json', 'right path';
is @{$m->stack}, 1, 'right number of elements';
$m = Mojolicious::Routes::Match->new(get => '/format3/baz.html')->match($r);
$m = Mojolicious::Routes::Match->new(GET => '/format3/baz.html')->match($r);
is $m->stack->[0]->{controller}, 'me', 'right value';
is $m->stack->[0]->{action}, 'bye', 'right value';
is $m->stack->[0]->{format}, 'html', 'right value';
Expand All @@ -385,7 +385,7 @@ is $m->stack->[0]->{action}, 'get', 'right value';
is $m->stack->[0]->{format}, 'html', 'right value';
is $m->path_for, '/method/get', 'right path';
is @{$m->stack}, 1, 'right number of elements';
$m = Mojolicious::Routes::Match->new(post => '/method/post')->match($r);
$m = Mojolicious::Routes::Match->new(POST => '/method/post')->match($r);
is $m->stack->[0]->{controller}, 'method', 'right value';
is $m->stack->[0]->{action}, 'post', 'right value';
is $m->stack->[0]->{format}, undef, 'no value';
Expand Down

0 comments on commit 735d4ab

Please sign in to comment.