| 1 | package Tak::Role::ObjectMangling; | ||
| 2 | |||
| 3 | 1 | ▶ | use Scalar::Util qw(weaken); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use JSON::PP qw(encode_json decode_json); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | ▶ | use Moo::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 1 | requires 'inflate'; | |
| 9 | 1 | requires 'deflate'; | |
| 10 | |||
| 11 | 1 | has encoder_json => (is => 'lazy'); | |
| 12 | 1 | has decoder_json => (is => 'lazy'); | |
| 13 | |||
| 14 | sub _build_encoder_json { | ||
| 15 | 0 | ▶ | JSON::PP->new->allow_nonref(1)->convert_blessed(1); |
|
Subroutine
_build_encoder_json: not called CC=1 SCAR=6.9
| |||
| 16 | } | ||
| 17 | |||
| 18 | sub _build_decoder_json { | ||
| 19 | 0 | ▶ | my $self = shift; |
|
Subroutine
_build_decoder_json: not called CC=1 SCAR=6.9
| |||
| 20 | 0 | weaken($self); | |
| 21 | JSON::PP->new->allow_nonref(1)->filter_json_single_key_object( | ||
| 22 | 0 | ▶ | __proxied_object__ => sub { $self->inflate($_[0]) } |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 23 | 0 | ); | |
| 24 | } | ||
| 25 | |||
| 26 | sub encode_objects { | ||
| 27 | 0 | ▶ | my ($self, $data) = @_; |
|
Subroutine
encode_objects: not called CC=1 SCAR=6.9
| |||
| 28 | 0 | ▶ | local *UNIVERSAL::TO_JSON = sub { $self->deflate($_[0]) }; |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 29 | 0 | decode_json($self->encoder_json->encode($data)); | |
| 30 | } | ||
| 31 | |||
| 32 | sub decode_objects { | ||
| 33 | 0 | ▶ | my ($self, $data) = @_; |
|
Subroutine
decode_objects: not called CC=1 SCAR=6.9
| |||
| 34 | 0 | $self->decoder_json->decode(encode_json($data)); | |
| 35 | } | ||
| 36 | |||