File Coverage

blib/lib/Path/Dispatcher/Role/Rules.pm
Criterion Covered Total %
statement 18 22 81.8
branch n/a
condition 1 6 16.6
subroutine 6 7 85.7
pod 2 3 66.6
total 27 38 71.0


line stmt bran cond sub pod time code
1             package Path::Dispatcher::Role::Rules;
2             # ABSTRACT: "has a list of rules"
3              
4             our $VERSION = '1.07';
5              
6 31     31   304236 use Moo::Role;
  31         81  
  31         187  
7 31     31   11618 use Carp qw(confess);
  31         89  
  31         1811  
8 31     31   235 use Types::Standard qw(ArrayRef);
  31         96  
  31         250  
9              
10             has _rules => (
11             is => 'ro',
12             isa => ArrayRef,
13             init_arg => 'rules',
14             default => sub { [] },
15             );
16              
17             sub add_rule {
18 27     27 1 1854 my $self = shift;
19              
20             $_->isa('Path::Dispatcher::Rule')
21             or confess "$_ is not a Path::Dispatcher::Rule"
22 27   33     210 for @_;
23              
24 27         59 push @{ $self->{_rules} }, @_;
  27         109  
25             }
26              
27             sub unshift_rule {
28 0     0 0 0 my $self = shift;
29              
30             $_->isa('Path::Dispatcher::Rule')
31             or confess "$_ is not a Path::Dispatcher::Rule"
32 0   0     0 for @_;
33              
34 0         0 unshift @{ $self->{_rules} }, @_;
  0         0  
35             }
36              
37 256     256 1 410 sub rules { @{ shift->{_rules} } }
  256         803  
38              
39 31     31   24541 no Moo::Role;
  31         90  
  31         166  
40              
41             1;
42              
43             __END__