File Coverage

blib/lib/UserAgent/Any/JSON/Response.pm
Criterion Covered Total %
statement 14 14 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 19 19 100.0


line stmt bran cond sub pod time code
1             package UserAgent::Any::JSON::Response;
2              
3 4     4   109 use 5.036;
  4         18  
4              
5 4     4   26 use Carp;
  4         9  
  4         439  
6 4     4   30 use Moo;
  4         7  
  4         37  
7 4     4   1552 use Scalar::Util 'blessed';
  4         10  
  4         360  
8              
9 4     4   2253 use namespace::clean;
  4         79419  
  4         30  
10              
11             our $VERSION = 0.03;
12              
13             extends 'UserAgent::Any::Response';
14              
15             has _converter => (
16             init_arg => 'converter',
17             is => 'ro',
18             lazy => 1,
19             default => sub { require JSON; JSON->new },
20             );
21              
22             has json => (
23             is => 'ro',
24             lazy => 1,
25             # TODO: here we should maybe check the Content-Type header of the response
26             # (for application/json) before proceeding.
27             default => sub ($self) { return $self->_converter->decode($self->content) },
28             );
29              
30             1;
31              
32             __END__