File Coverage

blib/lib/Plack/Middleware/Scope/Container.pm
Criterion Covered Total %
statement 29 29 100.0
branch 4 4 100.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 41 41 100.0


line stmt bran cond sub pod time code
1             package Plack::Middleware::Scope::Container;
2              
3 4     4   32171 use strict;
  4         8  
  4         159  
4 4     4   20 use warnings;
  4         8  
  4         136  
5 4     4   865 use parent qw(Plack::Middleware);
  4         860  
  4         31  
6 4     4   29152 use Scope::Container;
  4         674  
  4         319  
7 4     4   26 use Plack::Util;
  4         11  
  4         1063  
8              
9             our $VERSION = '0.04';
10              
11             sub call {
12 6     6 1 210427 my ( $self, $env) = @_;
13 6         27 my $container = start_scope_container();
14 6         107 my $res = $self->app->($env);
15             Plack::Util::response_cb($res, sub {
16 6     6   237 my $res = shift;
17 6 100       28 if ( defined $res->[2] ) {
18 4         8 undef $container;
19 4         24 return;
20             }
21             return sub {
22 6         266 my $chunk = shift;
23 6 100       12 if ( ! defined $chunk ) {
24 2         3 undef $container;
25 2         8 return;
26             }
27 4         23 return $chunk;
28 2         7 };
29 6         469 });
30             }
31              
32             1;
33             __END__