File Coverage

blib/lib/Amon2/ContextGuard.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 25 26 96.1


line stmt bran cond sub pod time code
1             package Amon2::ContextGuard;
2             # THIS IS INTERNAL CLASS.
3             # DO NOT USE THIS CLASS DIRECTLY.
4 25     25   220 use strict;
  25         53  
  25         727  
5 25     25   122 use warnings;
  25         54  
  25         620  
6 25     25   3002 use utf8;
  25         105  
  25         218  
7              
8             sub new {
9 25     25 0 1696 my ($class, $context, $dst) = @_;
10 25         55 my $orig = $$dst;
11 25         47 $$dst = $context;
12 25         84 bless [$orig, $dst], $class;
13             }
14              
15             sub DESTROY {
16 25     25   3414 my $self = shift;
17              
18             # paranoia: guard against cyclic reference
19 25         49 delete ${$self->[1]}->{$_} for keys %{${$self->[1]}};
  25         40  
  25         122  
  54         135  
20              
21 25         53 ${$self->[1]} = $self->[0];
  25         254  
22             }
23              
24             1;
25