| 1 | package DBIO::InflateColumn::Serializer::JSON; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: JSON Inflator | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 3 | our $VERSION = '0.900007'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use JSON::MaybeXS; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 3 | ▶ | sub get_freezer { | ||||||||||||||||||||||||||
|
Subroutine
get_freezer: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | 3 | my ($class, $column, $info, $args) = @_; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 3 | my $serializer = JSON::MaybeXS->new(_json_options($info)); | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 3 | ▶ | if (defined $info->{'size'}){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 1 | my $size = $info->{'size'}; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||
| 23 | 1 | my $s = $serializer->encode(shift); | |||||||||||||||||||||||||||
| 24 | 1 | ▶ | croak "serialization too big" if (length($s) > $size); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | 0 | return $s; | |||||||||||||||||||||||||||
| 26 | 1 | }; | |||||||||||||||||||||||||||
| 27 | } else { | ||||||||||||||||||||||||||||
| 28 | 4 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 4 | return $serializer->encode(shift); | |||||||||||||||||||||||||||
| 30 | 2 | }; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 3 | ▶ | sub get_unfreezer { | ||||||||||||||||||||||||||
|
Subroutine
get_unfreezer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 3 | my ($class, $column, $info, $args) = @_; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 4 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 39 | 4 | JSON::MaybeXS->new(_json_options($info))->decode(shift); | |||||||||||||||||||||||||||
| 40 | 3 | }; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 7 | ▶ | sub _json_options { | ||||||||||||||||||||||||||
|
Subroutine
_json_options: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 44 | 7 | my ($info) = @_; | |||||||||||||||||||||||||||
| 45 | 7 | my $opts = $info->{serializer_options}; | |||||||||||||||||||||||||||
| 46 | 7 | ▶ | return ( canonical => 1, convert_blessed => 1, $opts && %$opts ? %$opts : () ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opts and %$opts
MC/DC50%1/2
$opts and %$opts
$opts
%$opts
Truth table66%2/3
A and B
A= $optsB= %$opts
| |||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 3 | 1; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | __END__ | ||||||||||||||||||||||||||||