File Coverage

blib/lib/Thunderhorse/Request.pm
Criterion Covered Total %
statement 40 40 100.0
branch 3 4 75.0
condition 2 3 66.6
subroutine 8 8 100.0
pod 2 3 66.6
total 55 58 94.8


line stmt bran cond sub pod time code
1             package Thunderhorse::Request;
2             $Thunderhorse::Request::VERSION = '0.102';
3 21     21   316 use v5.40;
  21         89  
4 21     21   140 use Mooish::Base -standard;
  21         42  
  21         218  
5              
6 21     21   364669 use Future::AsyncAwait;
  21         52  
  21         291  
7 21     21   1556 use Gears::X::Thunderhorse;
  21         46  
  21         1027  
8 21     21   191 use List::Util qw(mesh);
  21         42  
  21         13835  
9              
10             extends 'PAGI::Request';
11             with 'Thunderhorse::Message';
12              
13 101         210 sub FOREIGNBUILDARGS ($class, %args)
14 101     101 0 44256 {
  101         247  
  101         213  
15             Gears::X::Thunderhorse->raise('no context for response')
16 101 50       455 unless $args{context};
17              
18 101         1152 return $args{context}->pagi->@[0, 1];
19             }
20              
21 101         269 sub update ($self, $scope, $receive, $send)
  101         141  
  101         149  
22 101     101 1 209 {
  101         147  
  101         131  
23 101         220 $self->{scope} = $scope;
24 101         253 $self->{receive} = $receive;
25              
26             # handling next match, so make sure path_params are invalidated
27 101         240 delete $self->{path_params};
28             }
29              
30             sub path_params ($self)
31 6     6 1 274 {
  6         8  
  6         6  
32 6   66     17 return $self->{path_params} //= do {
33 2         6 my $ctx = $self->context;
34 2         5 my $match = $ctx->match;
35 2 100       6 $match = $match->[0]
36             if ref $match eq 'ARRAY';
37              
38 2         26 my $pattern = $match->location->pattern_obj;
39 2         13 my $matched = $match->matched;
40 2         6 +{mesh [map { $_->{label} } $pattern->tokens->@*], $matched};
  4         57  
41             };
42             }
43              
44             __END__