line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Articulate::Serialisation::Asset; |
2
|
1
|
|
|
1
|
|
893
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
18
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
3
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
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} |
|
|
|
0
|
|
|
|
|
25
|
|
|
|
|
|
|
and ref $response->data->{$type} eq ref {} |
26
|
|
|
|
|
|
|
and $response->data->{$type}->{schema}->{core}->{file} ) |
27
|
|
|
|
|
|
|
{ |
28
|
0
|
|
0
|
|
|
|
my $content_type = |
29
|
|
|
|
|
|
|
$response->data->{$type}->{schema}->{core}->{content_type} // $type; |
30
|
0
|
|
|
|
|
|
$self->framework->set_content_type($content_type); |
31
|
0
|
|
0
|
|
|
|
my $content = $response->data->{$type}->{content} // ''; |
32
|
0
|
|
|
|
|
|
return $content; |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
|
return undef; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |