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.08';
5              
6 31     31   17052 use Moo::Role;
  31         79  
  31         579  
7 31     31   15100 use Carp qw(confess);
  31         92  
  31         1704  
8 31     31   233 use Types::Standard qw(ArrayRef);
  31         115  
  31         262  
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 999 my $self = shift;
19              
20             $_->isa('Path::Dispatcher::Rule')
21             or confess "$_ is not a Path::Dispatcher::Rule"
22 27   33     214 for @_;
23              
24 27         55 push @{ $self->{_rules} }, @_;
  27         108  
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 423 sub rules { @{ shift->{_rules} } }
  256         808  
38              
39 31     31   24203 no Moo::Role;
  31         78  
  31         223  
40              
41             1;
42              
43             __END__
44              
45             =pod
46              
47             =encoding UTF-8
48              
49             =head1 NAME
50              
51             Path::Dispatcher::Role::Rules - "has a list of rules"
52              
53             =head1 VERSION
54              
55             version 1.08
56              
57             =head1 DESCRIPTION
58              
59             Classes that compose this role get the following things:
60              
61             =head1 ATTRIBUTES
62              
63             =head2 _rules
64              
65             =head1 METHODS
66              
67             =head2 rules
68              
69             =head2 add_rule
70              
71             =head1 SUPPORT
72              
73             Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Path-Dispatcher>
74             (or L<bug-Path-Dispatcher@rt.cpan.org|mailto:bug-Path-Dispatcher@rt.cpan.org>).
75              
76             =head1 AUTHOR
77              
78             Shawn M Moore, C<< <sartak at bestpractical.com> >>
79              
80             =head1 COPYRIGHT AND LICENSE
81              
82             This software is copyright (c) 2020 by Shawn M Moore.
83              
84             This is free software; you can redistribute it and/or modify it under
85             the same terms as the Perl 5 programming language system itself.
86              
87             =cut