blib/lib/DBIO/InflateColumn/Serializer/JSON.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 11 / 11 Podpod 100% 2 / 2 totaltotal 92.9% 53 / 57 CC 5 SCAR 5.3
CC
5
Cov
93%
_json_options
3.0
__ANON__
2.3
get_freezer
2.0
CRAP 1.7
« blib/lib/DBIO/Future.pm ↑ Summary blib/lib/DBIO/Replicated/Backend/Replicant.pm »
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
BranchTrueFalseTotal
if (defined $info->{'size'}) { } 1 2 3
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
BranchTrueFalseTotal
if length $s > $size 1 0 1
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
BranchTrueFalseTotal
$opts && %$opts ? : 2 5 7
Condition66%2/3
$opts and %$opts
!ll&&!rl&&r
502
MC/DC50%1/2
$opts and %$opts
$opts %$opts
Truth table66%2/3
A and B
A= $optsB= %$opts
ABresult
0X0
100
111
47 }
48  
49  
50 3 1;
51  
52 __END__
« blib/lib/DBIO/Future.pm ↑ Summary blib/lib/DBIO/Replicated/Backend/Replicant.pm »