blib/lib/Jedi/Response.pm

filter: Statementstmt 100% 26 / 26 Branchbran 100% 4 / 4 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 100% 46 / 46 SCAR 13.9
CC
4
Cov
100%
to_psgi
3.0
push_header
2.0
BEGIN
1.0
CRAP 4.0
« blib/lib/Jedi.pm ↑ Summary blib/lib/Jedi/Helpers/Hash.pm »
1 #
2 # This file is part of Jedi
3 #
4 # This software is copyright (c) 2013 by celogeek <me@celogeek.com>.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 package Jedi::Response;
10  
11 # ABSTRACT: response object
12  
13 8 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 8 our $VERSION = '1.006'; # VERSION
16  
17 8 ▶use Jedi::Helpers::Hash;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 59 ▶has 'status' => ( is => 'rw', default => sub {404} );
Subroutine __ANON__: called CC=1 SCAR=0.0
20  
21 61 ▶has 'headers' => ( is => 'ro', default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
22  
23 sub set_header {
24 2 ▶ my ( $self, $header_name, $header_value ) = @_;
Subroutine set_header: called CC=1 SCAR=0.0
Pod documented
25 2 $self->headers->{$header_name} = [$header_value];
26 2 return;
27 }
28  
29 sub push_header {
30 2 ▶ my ( $self, $header_name, $header_value ) = @_;
Subroutine push_header: called CC=2 SCAR=6.9
Pod documented
31 2 ▶ if ( exists $self->headers->{$header_name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->headers->{$header_name}) { } 1 1 2
32 1 push @{ $self->headers->{$header_name} }, $header_value;
33 }
34 else {
35 1 $self->set_header( $header_name, $header_value );
36 }
37 2 return;
38 }
39  
40 59 ▶has 'body' => ( is => 'rw', default => sub {''} );
Subroutine __ANON__: called CC=1 SCAR=0.0
41  
42 sub to_psgi {
43 59 ▶ my ($self) = @_;
Subroutine to_psgi: called CC=3 SCAR=11.0
Pod documented
44  
45 59 ▶ $self->body('No route found !')
Branch: 1 branch
BranchTrueFalseTotal
if $self->status == 404 and not length $self->body 1 58 59
Condition100%3/3
$self->status == 404 and not length $self->body
!ll&&!rl&&r
5711
MC/DC100%2/2
$self->status == 404 and not length $self->body
$self->status == 404 not length $self->body
Truth table100%3/3
A and not(B)
A= $self->status == 404B= not length $self->body
ABresult
0X0
100
111
46 if $self->status == 404 && !length( $self->body );
47  
48 59 return [ $self->status, $self->headers->to_arrayref, [ $self->body ] ];
49 }
50  
51 8 1;
52  
53 __END__
« blib/lib/Jedi.pm ↑ Summary blib/lib/Jedi/Helpers/Hash.pm »