File Coverage

blib/lib/Data/Encoder/JSON.pm
Criterion Covered Total %
statement 19 19 100.0
branch 1 2 50.0
condition 2 2 100.0
subroutine 6 6 100.0
pod 0 3 0.0
total 28 32 87.5


line stmt bran cond sub pod time code
1             package Data::Encoder::JSON;
2              
3 2     2   322 use strict;
  2         4  
  2         55  
4 2     2   8 use warnings;
  2         2  
  2         51  
5 2     2   11 use JSON;
  2         684  
  2         10  
6              
7             sub new {
8 3     3 0 936 my ($class, $args) = @_;
9 3         24 my $json = JSON->new;
10              
11 3   100     16 $args ||= {};
12 3         10 for my $method (keys %$args) {
13 1 50       10 $json->$method(defined $args->{$method} ? $args->{$method} : ());
14             }
15              
16             bless {
17 3         11 json => $json,
18             }, __PACKAGE__;
19             }
20              
21             sub encode {
22 3     3 0 16 my ($self, $stuff, @args) = @_;
23 3         56 $self->{json}->encode($stuff, @args);
24             }
25              
26             sub decode {
27 1     1 0 385 my ($self, $stuff, @args) = @_;
28 1         11 $self->{json}->decode($stuff, @args);
29             }
30              
31             1;
32             __END__