File Coverage

blib/lib/Data/Resolver/RoleComplain.pm
Criterion Covered Total %
statement 41 44 93.1
branch 2 6 33.3
condition 1 2 50.0
subroutine 11 11 100.0
pod 2 2 100.0
total 57 65 87.6


line stmt bran cond sub pod time code
1             #!/usr/bin/env perl
2             package Data::Resolver::RoleComplain;
3 6     6   71768 use v5.24;
  6         25  
4 6     6   34 use warnings;
  6         32  
  6         372  
5 6     6   35 use experimental 'signatures';
  6         13  
  6         48  
6 6     6   1214 use Carp;
  6         13  
  6         558  
7 6     6   42 use Moo::Role;
  6         17  
  6         50  
8 6     6   4447 no warnings 'experimental::signatures';
  6         29  
  6         293  
9 6     6   32 use namespace::clean;
  6         11  
  6         49  
10              
11             has _ouch => (is => 'lazy', init_arg => 'ouch');
12              
13             has use_ouch => (is => 'lazy', init_arg => undef);
14              
15 16   50 16   190 sub _build__ouch ($self) { $Data::Resolver::RoleComplain::use_ouch // 0 }
  16         35  
  16         33  
  16         400  
16              
17 3     3   35 sub _build_use_ouch ($self) {
  3         7  
  3         6  
18 3 50       98 my $ouch = $self->_ouch or return 0;
19 0         0 require Ouch;
20 0 0       0 Ouch->import($ouch->@*) if ref($ouch) eq 'ARRAY';
21 0         0 return 1;
22             } ## end sub _build_use_ouch
23              
24 4     4 1 7468 sub complain ($self, $code, $message, $data = undef) { # Ouch-compatible
  4         8  
  4         10  
  4         9  
  4         9  
  4         7  
25 4 50       144 return Ouch::ouch($code, $message, $data) if $self->use_ouch;
26 4         162 croak "[$code] $message";
27             }
28              
29 1     1 1 1166 sub not_found ($self, $key) { $self->complain(404, "Not Found: <$key>") }
  1         2  
  1         3  
  1         2  
  1         5  
30              
31             1;