File Coverage

blib/lib/ASP4/Mock/Pool.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 1 3 33.3
total 26 28 92.8


line stmt bran cond sub pod time code
1              
2             package ASP4::Mock::Pool;
3              
4 9     9   32 use strict;
  9         10  
  9         231  
5 9     9   27 use warnings 'all';
  9         9  
  9         1310  
6              
7 5130     5130 0 19435 sub new { return bless { cleanup_handlers => [ ] }, shift }
8             sub call_cleanup_handlers {
9 5124     5124 0 3656 my $s = shift;
10 5124         4078 map { $_->( ) } @{ $s->{cleanup_handlers} }
  1         4  
  5124         7355  
11             }
12             sub cleanup_register {
13 1     1 1 3 my ($s, $handler, $args) = @_;
14            
15 1     1   3 push @{ $s->{cleanup_handlers} }, sub { $handler->( $args ) };
  1         18  
  1         4  
16             }
17              
18             sub DESTROY
19             {
20 5124     5124   4042 my $s = shift;
21 5124         7942 $s->call_cleanup_handlers();
22 5124         23137 undef(%$s);
23             }# end DESTROY()
24              
25             1;# return true:
26              
27             =pod
28              
29             =head1 NAME
30              
31             ASP4::Mock::Pool - Mimics the $r->pool APR::Pool object
32              
33             =head1 SYNOPSIS
34              
35             my $pool = $r->pool;
36             $pool->cleanup_register( sub { ... }, \@args );
37              
38             =head1 DESCRIPTION
39              
40             This package mimics the L object obtained via $r->pool in a normal mod_perl2 environment.
41              
42             =head1 PUBLIC METHODS
43              
44             =head2 cleanup_register( sub { ... }, \@args )
45              
46             Causes the subref to be executed with C<\@args> at the end of the current request.
47              
48             =cut
49