Spore/Middleware/Format/Auto.pm

filter: Statementstmt 41.9% 13 / 31 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 100% 1 / 1 totaltotal 37.7% 17 / 45 CC 5 SCAR 22.0
CC
5
Cov
35%
call
20.0
__ANON__
6.0
__ANON__
2.0
CRAP 9.0
« Spore/Role/Request.pm ↑ Summary Spore/Request.pm »
1 package Net::HTTP::Spore::Middleware::Format::Auto;
2 2 $Net::HTTP::Spore::Middleware::Format::Auto::VERSION = '0.09';
3 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use MooseX::Types::Moose qw/HashRef Object/;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 extends 'Net::HTTP::Spore::Middleware::Format';
6  
7 2 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 has serializer => (
10 is => 'rw',
11 isa => HashRef [Object],
12 lazy => 1,
13 0 ▶ default => sub { {} },
Subroutine __ANON__: not called CC=1 SCAR=6.9
14 2 );
15  
16 0 ▶sub call {
Subroutine call: not called CC=4 SCAR=30.0
Pod documented
17 0 my ( $self, $req ) = @_;
18  
19 0 my $formats = $req->env->{'spore.format'};
20  
21 0 foreach my $format (@$formats) {
22 0 my $cls = "Net::HTTP::Spore::Middleware::Format::" . $format;
23 0 ▶ if ( Class::MOP::load($cls) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (Class::MOP::load($cls)) 0 0 0
24 0 my $s = $cls->new;
25 0 $self->serializer->{$format} = $s;
26 0 ▶ try {
Subroutine __ANON__: not called CC=2 SCAR=17.9
27 0 ▶ if ( $req->env->{'spore.payload'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->env->{"spore.payload"}) 0 0 0
28 $req->env->{'spore.payload'} =
29 0 $s->encode( $req->env->{'spore.payload'} );
30 0 $req->header( $s->content_type );
31 }
32 0 $req->header( $s->accept_type );
33 0 $req->env->{$self->serializer_key} = 1;
34 0 };
35 0 ▶ last if $req->env->{$self->serializer_key} == 1;
Branch: 1 branch
BranchTrueFalseTotal
if $req->env->{$self->serializer_key} == 1 0 0 0
36 }
37 }
38  
39 return $self->response_cb(
40 0 ▶ sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
41 0 my $res = shift;
42 0 return $res;
43 }
44 0 );
45 }
46  
47 2 1;
48  
49 __END__
« Spore/Role/Request.pm ↑ Summary Spore/Request.pm »