blib/lib/Dancer2/Serializer/JSONMaybeXS.pm

filter: Statementstmt 100% 21 / 21 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 3 totaltotal 86.1% 31 / 36 CC 5 SCAR 8.8
CC
5
Cov
93%
serialize
4.0
deserialize
2.0
BEGIN
1.0
CRAP 2.4
↑ Summary
1 package Dancer2::Serializer::JSONMaybeXS;
2  
3 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use JSON::MaybeXS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '0.003';
7  
8 1 with 'Dancer2::Core::Role::Serializer';
9  
10 7 ▶has '+content_type' => ( default => sub {'application/json;charset=UTF-8'} );
Subroutine __ANON__: called CC=1 SCAR=0.0
11  
12 7 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
13 7 warnings::warnif('deprecated',
14 'Dancer2::Serializer::JSONMaybeXS is deprecated and should no longer be used');
15 }
16  
17 14 ▶sub serialize {
Subroutine serialize: called CC=4 SCAR=13.9
Pod undocumented
18 14 my ($self, $entity, $options) = @_;
19
20 14 my $config = $self->config;
21
22 14 foreach (keys %$config) {
23 16 ▶ $options->{$_} = $config->{$_} unless exists $options->{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $options->{$_} 16 0 16
24 }
25
26 14 ▶ $options->{utf8} = 1 if !defined $options->{utf8};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options->{"utf8"} 13 1 14
27
28 14 JSON::MaybeXS->new($options)->encode($entity);
29 }
30  
31 7 ▶sub deserialize {
Subroutine deserialize: called CC=2 SCAR=7.1
Pod undocumented
32 8 my ($self, $entity, $options) = @_;
33
34 8 ▶ $options->{utf8} = 1 if !defined $options->{utf8};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $options->{"utf8"} 7 0 7
35 8 JSON::MaybeXS->new($options)->decode($entity);
36 }
37  
38 1 1;
39  
40 =head1 NAME
41  
42 Dancer2::Serializer::JSONMaybeXS - (DEPRECATED) Serializer for handling JSON data
43  
44 =head1 SYNOPSIS
45  
46 use Dancer2;
47 set serializer => 'JSONMaybeXS';
48  
49 =head1 DESCRIPTION
50  
51 This is a DEPRECATED serializer engine for the L<Dancer2> web framework.
52 L<Dancer2> now uses L<JSON::MaybeXS> natively in the default
53 L<Dancer2::Serializer::JSON> (as of version C<0.201000>), so this module is no
54 longer needed.
55  
56 =head1 BUGS
57  
58 Report any issues on the public bugtracker.
59  
60 =head1 AUTHOR
61  
62 Dan Book <dbook@cpan.org>
63  
64 =head1 COPYRIGHT AND LICENSE
65  
66 This software is Copyright (c) 2016 by Dan Book.
67  
68 This is free software, licensed under:
69  
70 The Artistic License 2.0 (GPL Compatible)
71  
72 =head1 SEE ALSO
73  
74 L<Dancer2::Serializer::JSON>
↑ Summary