File Coverage

blib/lib/Path/Dispatcher/Rule/Alternation.pm
Criterion Covered Total %
statement 16 16 100.0
branch 4 4 100.0
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 24 25 96.0


line stmt bran cond sub pod time code
1             package Path::Dispatcher::Rule::Alternation;
2             # ABSTRACT: any rule must match
3              
4             our $VERSION = '1.08';
5              
6 31     31   221 use Moo;
  31         66  
  31         194  
7             extends 'Path::Dispatcher::Rule';
8              
9             with 'Path::Dispatcher::Role::Rules';
10              
11             sub _match {
12 15     15   24 my $self = shift;
13 15         22 my $path = shift;
14              
15 15         128 my @rules = $self->rules;
16 15 100       47 return if @rules == 0;
17              
18 14         29 for my $rule (@rules) {
19 20 100       64 return {} if $rule->match($path);
20             }
21              
22 7         16 return;
23             }
24              
25             sub complete {
26 9     9 0 17 my $self = shift;
27              
28 9         22 return map { $_->complete(@_) } $self->rules;
  18         46  
29             }
30              
31             __PACKAGE__->meta->make_immutable;
32 31     31   16002 no Moo;
  31         111  
  31         161  
33              
34             1;
35              
36             __END__
37              
38             =pod
39              
40             =encoding UTF-8
41              
42             =head1 NAME
43              
44             Path::Dispatcher::Rule::Alternation - any rule must match
45              
46             =head1 VERSION
47              
48             version 1.08
49              
50             =head1 SYNOPSIS
51              
52             =head1 DESCRIPTION
53              
54             =head1 ATTRIBUTES
55              
56             =head2 rules
57              
58             =head1 SUPPORT
59              
60             Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Path-Dispatcher>
61             (or L<bug-Path-Dispatcher@rt.cpan.org|mailto:bug-Path-Dispatcher@rt.cpan.org>).
62              
63             =head1 AUTHOR
64              
65             Shawn M Moore, C<< <sartak at bestpractical.com> >>
66              
67             =head1 COPYRIGHT AND LICENSE
68              
69             This software is copyright (c) 2020 by Shawn M Moore.
70              
71             This is free software; you can redistribute it and/or modify it under
72             the same terms as the Perl 5 programming language system itself.
73              
74             =cut