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 4     4   2261 use strict;
  4         8  
  4         133  
3 4     4   19 use warnings;
  4         6  
  4         119  
4              
5 4     4   17 use Moo;
  4         5  
  4         20  
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;