blib/lib/Server/Starter/Guard.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 11 | 11 | 100.0 |
branch | 2 | 2 | 100.0 |
condition | n/a | ||
subroutine | 5 | 5 | 100.0 |
pod | 0 | 2 | 0.0 |
total | 18 | 20 | 90.0 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package Server::Starter::Guard; | ||||||
2 | |||||||
3 | 65 | 65 | 966 | use strict; | |||
65 | 110 | ||||||
65 | 2004 | ||||||
4 | 65 | 65 | 278 | use warnings; | |||
65 | 99 | ||||||
65 | 7352 | ||||||
5 | |||||||
6 | sub new { | ||||||
7 | 78 | 78 | 0 | 7317 | my ($klass, $handler) = @_; | ||
8 | 78 | 2176 | return bless { | ||||
9 | handler => $handler, | ||||||
10 | active => 1, | ||||||
11 | }, $klass; | ||||||
12 | } | ||||||
13 | |||||||
14 | 5 | 5 | 0 | 192 | sub dismiss { shift->{active} = 0 } | ||
15 | |||||||
16 | sub DESTROY { | ||||||
17 | 32 | 32 | 1002787 | my $self = shift; | |||
18 | 32 | 100 | 3278 | $self->{active} && $self->{handler}->(); | |||
19 | } | ||||||
20 | |||||||
21 | 1; |