Skip to content

Commit

Permalink
make captures return all captures from all parents
Browse files Browse the repository at this point in the history
  • Loading branch information
vti committed Jan 3, 2016
1 parent 90a8352 commit a82b864
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
14 changes: 2 additions & 12 deletions lib/Routes/Tiny/Match.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,10 @@ sub params { &captures }
sub captures {
my $self = shift;

return $self->{captures};
}

sub cascading_captures {
my $self = shift;

my $captures = $self->captures;
my $captures = $self->{captures};

return $self->parent ? {
%{$self->parent->cascading_captures},
%{$self->parent->captures},
%$captures
} : $captures;
}
Expand Down Expand Up @@ -94,10 +88,6 @@ Get route's pattern arguments.
Get params.
=head2 cascading_captures
Get params as well as parent and ancestor params in one hash.
=head2 C<params>
An alias to C<captures>.
Expand Down
2 changes: 1 addition & 1 deletion t/subroutes.t
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ subtest 'cascading captures' => sub {

my $match = $top->match('/top/rainbows/second/5/last/7/');

is_deeply $match->cascading_captures,
is_deeply $match->captures,
{
topic => 'rainbows',
parent_id => 5,
Expand Down

0 comments on commit a82b864

Please sign in to comment.