| 1 | package UserAgent::Any::JSON::Response; | ||
| 2 | |||
| 3 | 4 | ▶ | use 5.036; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 4 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 4 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 4 | ▶ | use Scalar::Util 'blessed'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 4 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 4 | our $VERSION = 0.03; | |
| 12 | |||
| 13 | 4 | extends 'UserAgent::Any::Response'; | |
| 14 | |||
| 15 | has _converter => ( | ||
| 16 | init_arg => 'converter', | ||
| 17 | is => 'ro', | ||
| 18 | lazy => 1, | ||
| 19 | 0 | ▶ | default => sub { require JSON; JSON->new }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 20 | 4 | ); | |
| 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 | 1 | ▶ | default => sub ($self) { return $self->_converter->decode($self->content) }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 28 | 4 | ); | |
| 29 | |||
| 30 | 4 | 1; | |
| 31 | |||
| 32 | __END__ | ||