line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tak::Role::ObjectMangling; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
553
|
use Scalar::Util qw(weaken); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
56
|
|
4
|
1
|
|
|
1
|
|
5
|
use JSON::PP qw(encode_json decode_json); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
requires 'inflate'; |
9
|
|
|
|
|
|
|
requires 'deflate'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has encoder_json => (is => 'lazy'); |
12
|
|
|
|
|
|
|
has decoder_json => (is => 'lazy'); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _build_encoder_json { |
15
|
0
|
|
|
0
|
|
|
JSON::PP->new->allow_nonref(1)->convert_blessed(1); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _build_decoder_json { |
19
|
0
|
|
|
0
|
|
|
my $self = shift; |
20
|
0
|
|
|
|
|
|
weaken($self); |
21
|
|
|
|
|
|
|
JSON::PP->new->allow_nonref(1)->filter_json_single_key_object( |
22
|
0
|
|
|
0
|
|
|
__proxied_object__ => sub { $self->inflate($_[0]) } |
23
|
0
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub encode_objects { |
27
|
0
|
|
|
0
|
0
|
|
my ($self, $data) = @_; |
28
|
1
|
|
|
1
|
|
424
|
no warnings 'once'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
129
|
|
29
|
0
|
|
|
0
|
|
|
local *UNIVERSAL::TO_JSON = sub { $self->deflate($_[0]) }; |
|
0
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
decode_json($self->encoder_json->encode($data)); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub decode_objects { |
34
|
0
|
|
|
0
|
0
|
|
my ($self, $data) = @_; |
35
|
0
|
|
|
|
|
|
$self->decoder_json->decode(encode_json($data)); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |