File Coverage

blib/lib/WebAPI/DBIC/Role/JsonEncoder.pm
Criterion Covered Total %
statement 6 9 66.6
branch 0 2 0.0
condition n/a
subroutine 2 3 66.6
pod n/a
total 8 14 57.1


line stmt bran cond sub pod time code
1             package WebAPI::DBIC::Role::JsonEncoder;
2             $WebAPI::DBIC::Role::JsonEncoder::VERSION = '0.003002';
3              
4 2     2   11108156 use JSON::MaybeXS qw(JSON);
  2         1902  
  2         182  
5              
6 2     2   1059 use Moo::Role;
  2         41687  
  2         11  
7              
8              
9             has _json_encoder => (
10             is => 'ro',
11             builder => '_build_json_encoder',
12             handles => {
13             encode_json => 'encode',
14             decode_json => 'decode',
15             },
16             );
17              
18             sub _build_json_encoder {
19 0     0     my $codec = JSON->new->ascii;
20 0 0         $codec->canonical->pretty if $ENV{WEBAPI_DBIC_DEBUG};
21 0           return $codec;
22             }
23              
24             1;
25              
26             __END__
27              
28             =pod
29              
30             =encoding UTF-8
31              
32             =head1 NAME
33              
34             WebAPI::DBIC::Role::JsonEncoder
35              
36             =head1 VERSION
37              
38             version 0.003002
39              
40             =head1 NAME
41              
42             WebAPI::DBIC::Resource::Role::JsonEncoder - provides encode_json and decode_json methods
43              
44             =head1 AUTHOR
45              
46             Tim Bunce <Tim.Bunce@pobox.com>
47              
48             =head1 COPYRIGHT AND LICENSE
49              
50             This software is copyright (c) 2015 by Tim Bunce.
51              
52             This is free software; you can redistribute it and/or modify it under
53             the same terms as the Perl 5 programming language system itself.
54              
55             =cut