line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Serializer for handling Dumper data |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$Dancer2::Serializer::Dumper::VERSION = '0.400000'; |
4
|
|
|
|
|
|
|
use Moo; |
5
|
4
|
|
|
4
|
|
63844
|
use Carp 'croak'; |
|
4
|
|
|
|
|
6930
|
|
|
4
|
|
|
|
|
24
|
|
6
|
4
|
|
|
4
|
|
2319
|
use Data::Dumper; |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
204
|
|
7
|
4
|
|
|
4
|
|
560
|
use Safe; |
|
4
|
|
|
|
|
6521
|
|
|
4
|
|
|
|
|
239
|
|
8
|
4
|
|
|
4
|
|
1813
|
|
|
4
|
|
|
|
|
125534
|
|
|
4
|
|
|
|
|
987
|
|
9
|
|
|
|
|
|
|
with 'Dancer2::Core::Role::Serializer'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has '+content_type' => ( default => sub {'text/x-data-dumper'} ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# helpers |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
1
|
46
|
|
16
|
|
|
|
|
|
|
# class definition |
17
|
7
|
|
|
7
|
1
|
146
|
my ( $self, $entity ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
{ |
20
|
|
|
|
|
|
|
local $Data::Dumper::Purity = 1; |
21
|
|
|
|
|
|
|
return Dumper($entity); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my ( $self, $content ) = @_; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $cpt = Safe->new; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $res = $cpt->reval("my \$VAR1; $content"); |
30
|
|
|
|
|
|
|
croak "unable to deserialize : $@" if $@; |
31
|
|
|
|
|
|
|
return $res; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=pod |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=encoding UTF-8 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Dancer2::Serializer::Dumper - Serializer for handling Dumper data |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 VERSION |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
version 0.400000 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This is a serializer engine that allows you to turn Perl data structures into |
52
|
|
|
|
|
|
|
L<Data::Dumper> output and vice-versa. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 content_type |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Returns 'text/x-data-dumper' |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 METHODS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 serialize($content) |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Serializes a Perl data structure into a Dumper string. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 deserialize($content) |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Deserialize a Dumper string into a Perl data structure. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 FUNCTIONS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 from_dumper($content) |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This is an helper available to transform a L<Data::Dumper> output to a Perl |
75
|
|
|
|
|
|
|
data structures. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 to_dumper($content) |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This is an helper available to transform a Perl data structures to a |
80
|
|
|
|
|
|
|
L<Data::Dumper> output. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Calling this function will B<not> trigger the serialization's hooks. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 AUTHOR |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Dancer Core Developers |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Alexis Sukrieh. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
93
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |