| 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.007'; # 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
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
$self->status == 404 and not length $self->body
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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||