OX/Application/Role/Request.pm

filter: Statementstmt 100% 25 / 25 Branchbran 100% 4 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 88.8% 8 / 9 Podpod 75.0% 3 / 4 totaltotal 91.4% 43 / 47 CC 4 SCAR 6.9
CC
4
Cov
97%
handle_response
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« OX/Application/Role/RouteBuilder.pm ↑ Summary OX/RouteBuilder.pm »
1 package OX::Application::Role::Request;
2 45 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 45 $OX::Application::Role::Request::AUTHORITY = 'cpan:STEVAN';
4 }
5 45 $OX::Application::Role::Request::VERSION = '0.14';
6 45 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 45 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 # ABSTRACT: application role to allow the use of request and response objects
9  
10 45 ▶use Class::Load 'load_class';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 0 ▶sub BUILD { }
Subroutine BUILD: not called CC=1 SCAR=0.0
Pod undocumented
14 97 ▶before BUILD => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
15 97 my $self = shift;
16  
17 97 load_class($self->request_class);
18 45 };
19  
20  
21 304 ▶sub request_class { 'OX::Request' }
Subroutine request_class: called CC=1 SCAR=0.0
Pod documented
22  
23  
24 207 ▶sub new_request {
Subroutine new_request: called CC=1 SCAR=0.0
Pod documented
25 207 my $self = shift;
26 207 my ($env) = @_;
27  
28 207 return $self->request_class->new(env => $env);
29 }
30  
31  
32 203 ▶sub handle_response {
Subroutine handle_response: called CC=4 SCAR=13.9
Pod documented
33 203 my $self = shift;
34 203 my ($res, $req) = @_;
35  
36 203 ▶ if (!ref($res)) {
Branch: 2 branches
BranchTrueFalseTotal
if (not ref $res) { } 131 72 203
elsif (not builtin::blessed($res) && $res->can('finalize')) { } 71 1 72
37 131 $res = $req->new_response([
38 200, [ 'Content-Type' => 'text/html' ], [ $res ]
39 ]);
40 }
41 ▶ elsif (!blessed($res) || !$res->can('finalize')) {
Condition66%2/3
builtin::blessed($res) && $res->can('finalize')
!ll&&!rl&&r
7101
MC/DC50%1/2
builtin::blessed($res) && $res->can('finalize')
builtin::blessed($res) $res->can('finalize')
Truth table66%2/3
A && B
A= builtin::blessed($res)B= $res->can('finalize')
ABresult
0X0
100
111
42 71 $res = $req->new_response($res);
43 }
44  
45 203 return $res->finalize;
46 }
47  
48  
49 45 1;
50  
51 __END__
« OX/Application/Role/RouteBuilder.pm ↑ Summary OX/RouteBuilder.pm »