File Coverage

blib/lib/Path/Dispatcher/Rule/Metadata.pm
Criterion Covered Total %
statement 12 12 100.0
branch 2 2 100.0
condition n/a
subroutine 3 3 100.0
pod n/a
total 17 17 100.0


line stmt bran cond sub pod time code
1             package Path::Dispatcher::Rule::Metadata;
2 32     32   125 use Any::Moose;
  32         40  
  32         151  
3             extends 'Path::Dispatcher::Rule';
4              
5             has field => (
6             is => 'ro',
7             isa => 'Str',
8             required => 1,
9             );
10              
11             has matcher => (
12             is => 'ro',
13             isa => 'Path::Dispatcher::Rule',
14             required => 1,
15             );
16              
17             sub _match {
18 3     3   6 my $self = shift;
19 3         5 my $path = shift;
20 3         15 my $got = $path->get_metadata($self->field);
21              
22             # wow, offensive.. but powerful
23 3         11 my $metadata_path = $path->clone_path($got);
24 3 100       99 return unless $self->matcher->match($metadata_path);
25              
26             return {
27 2         18 leftover => $path->path,
28             };
29             }
30              
31             __PACKAGE__->meta->make_immutable;
32 32     32   15442 no Any::Moose;
  32         62  
  32         101  
33              
34             1;
35              
36             __END__