line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Path::Dispatcher::Match; |
2
|
|
|
|
|
|
|
# ABSTRACT: the result of a successful rule match |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.07'; |
5
|
|
|
|
|
|
|
|
6
|
32
|
|
|
32
|
|
250
|
use Moo; |
|
32
|
|
|
|
|
80
|
|
|
32
|
|
|
|
|
317
|
|
7
|
|
|
|
|
|
|
|
8
|
32
|
|
|
32
|
|
27596
|
use Type::Utils qw(class_type); |
|
32
|
|
|
|
|
160012
|
|
|
32
|
|
|
|
|
309
|
|
9
|
32
|
|
|
32
|
|
18716
|
use Types::Standard qw(Str ArrayRef HashRef Undef); |
|
32
|
|
|
|
|
83
|
|
|
32
|
|
|
|
|
150
|
|
10
|
32
|
|
|
32
|
|
47270
|
use Path::Dispatcher::Path; |
|
32
|
|
|
|
|
168
|
|
|
32
|
|
|
|
|
1177
|
|
11
|
32
|
|
|
32
|
|
268
|
use Path::Dispatcher::Rule; |
|
32
|
|
|
|
|
73
|
|
|
32
|
|
|
|
|
10317
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has path => ( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
isa => class_type('Path::Dispatcher::Path'), |
16
|
|
|
|
|
|
|
required => 1, |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has leftover => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
isa => Str, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has rule => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
isa => class_type('Path::Dispatcher::Rule'), |
27
|
|
|
|
|
|
|
required => 1, |
28
|
|
|
|
|
|
|
handles => ['payload'], |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has positional_captures => ( |
32
|
|
|
|
|
|
|
is => 'ro', |
33
|
|
|
|
|
|
|
isa => ArrayRef[Str|Undef], |
34
|
|
|
|
|
|
|
default => sub { [] }, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has named_captures => ( |
38
|
|
|
|
|
|
|
is => 'ro', |
39
|
|
|
|
|
|
|
isa => HashRef[Str|Undef], |
40
|
|
|
|
|
|
|
default => sub { {} }, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has parent => ( |
44
|
|
|
|
|
|
|
is => 'ro', |
45
|
|
|
|
|
|
|
isa => class_type('Path::Dispatcher::Match'), |
46
|
|
|
|
|
|
|
predicate => 'has_parent', |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub run { |
50
|
69
|
|
|
69
|
1
|
1659
|
my $self = shift; |
51
|
|
|
|
|
|
|
|
52
|
69
|
|
|
|
|
263
|
local $_ = $self->path; |
53
|
69
|
|
|
|
|
549
|
return scalar $self->rule->run($self, @_); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub pos { |
57
|
9
|
|
|
9
|
1
|
2349
|
my $self = shift; |
58
|
9
|
|
|
|
|
18
|
my $index = shift; |
59
|
|
|
|
|
|
|
|
60
|
9
|
100
|
|
|
|
74
|
return undef if $index == 0; |
61
|
|
|
|
|
|
|
|
62
|
8
|
100
|
|
|
|
22
|
$index-- if $index > 0; |
63
|
|
|
|
|
|
|
|
64
|
8
|
|
|
|
|
48
|
return $self->positional_captures->[$index]; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub named { |
68
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
69
|
0
|
|
|
|
|
|
my $key = shift; |
70
|
0
|
|
|
|
|
|
return $self->named_captures->{$key}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
74
|
32
|
|
|
32
|
|
284
|
no Moo; |
|
32
|
|
|
|
|
77
|
|
|
32
|
|
|
|
|
231
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |