File Coverage

blib/lib/Articulate/Serialisation/StatusSetter.pm
Criterion Covered Total %
statement 9 15 60.0
branch 0 2 0.0
condition 0 5 0.0
subroutine 3 4 75.0
pod 1 1 100.0
total 13 27 48.1


line stmt bran cond sub pod time code
1             package Articulate::Serialisation::StatusSetter;
2 5     5   2350 use strict;
  5         11  
  5         151  
3 5     5   16 use warnings;
  5         9  
  5         92  
4              
5 5     5   17 use Moo;
  5         7  
  5         23  
6             with 'Articulate::Role::Component';
7              
8             =head1 NAME
9              
10             Articulate::Serialisation::StatusSetter - send the right HTTP status response
11              
12             =head1 METHODS
13              
14             =head3 serialise
15              
16             Sets the status of the Dancer response you're going to be sending to match the status of the Articulate Response.
17              
18             =cut
19              
20             sub serialise {
21 0     0 1   my $self = shift;
22 0           my $response = shift;
23 0 0 0       if ( ref $response and $response->can('http_code') ) {
24 0   0       $self->framework->status( $response->http_code // 500 );
25             }
26             else {
27 0           $self->framework->status(500);
28             }
29 0           return undef; # we want to continue with other serialisations
30             }
31              
32             1;