File Coverage

blib/lib/Articulate/Serialisation/Asset.pm
Criterion Covered Total %
statement 9 18 50.0
branch 0 2 0.0
condition 0 11 0.0
subroutine 3 4 75.0
pod 1 1 100.0
total 13 36 36.1


line stmt bran cond sub pod time code
1             package Articulate::Serialisation::Asset;
2 1     1   864 use strict;
  1         2  
  1         36  
3 1     1   6 use warnings;
  1         1  
  1         29  
4              
5 1     1   6 use Moo;
  1         2  
  1         6  
6             with 'Articulate::Role::Component';
7              
8             =head1 NAME
9              
10             Articulate::Serialisation::Asset - return your asset as a file
11              
12             =head1 METHODS
13              
14             =head3 serialise
15              
16             If the meta schema.core.file is true, send the file as a schema.core.content_type.
17              
18             =cut
19              
20             sub serialise {
21 0     0 1   my $self = shift;
22 0           my $response = shift;
23 0           my $type = $response->type;
24 0 0 0       if ( $response->data->{$type} and ref $response->data->{$type} eq ref {} and $response->data->{$type}->{schema}->{core}->{file} ) {
      0        
25 0   0       my $content_type = $response->data->{$type}->{schema}->{core}->{content_type} // $type ;
26 0           $self->framework->set_content_type ( $content_type );
27 0   0       my $content = $response->data->{$type}->{content} // '';
28 0           return $content;
29             }
30 0           return undef;
31             }
32              
33             1;