File Coverage

blib/lib/PX/API/Response.pm
Criterion Covered Total %
statement 16 18 88.8
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 22 24 91.6


line stmt bran cond sub pod time code
1             package PX::API::Response;
2 1     1   1822 use warnings;
  1         3  
  1         37  
3 1     1   6 use strict;
  1         2  
  1         149  
4 1     1   15 use Carp;
  1         2  
  1         82  
5              
6 1     1   5 use version; our $VERSION = qv('0.0.3');
  1         2  
  1         7  
7              
8 1     1   1753 use HTTP::Response;
  1         8846  
  1         71  
9             our @ISA = qw(HTTP::Response);
10              
11             use Module::Pluggable::Fast
12 0           name => 'response_plugins',
13 1     1   546 search => [ qw/PX::API::Response/ ];
  0            
14              
15              
16             sub new {
17             my $class = shift;
18             my $args = shift;
19              
20             my $self = HTTP::Response->new();
21             return bless $self, $class;
22             }
23              
24             sub _init {
25             my $self = shift;
26             my $args = shift;
27             my $format = $args->{'format'} || "rest";
28              
29             my @classes = $self->response_plugins;
30             foreach my $c(@classes) {
31             if ($c->format eq $format) {
32             $self->{'parser'} = $c;
33             last;
34             }
35             }
36             return $self;
37             }
38              
39             sub fault {
40             my ($self,$err_code,$err_string) = @_;
41             $self->{success} = 0;
42             $self->{err_code} = $err_code;
43             $self->{err_string} = $err_string;
44             }
45              
46             sub success {
47             my ($self,$ref) = @_;
48             $self->{success} = 1;
49             $self->{response} = $ref;
50             }
51              
52              
53             1;
54             __END__