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   187 use strict;
  25         54  
  25         735  
5 25     25   135 use warnings;
  25         46  
  25         575  
6 25     25   3064 use utf8;
  25         108  
  25         205  
7              
8             sub new {
9 25     25 0 1727 my ($class, $context, $dst) = @_;
10 25         48 my $orig = $$dst;
11 25         43 $$dst = $context;
12 25         77 bless [$orig, $dst], $class;
13             }
14              
15             sub DESTROY {
16 25     25   3339 my $self = shift;
17              
18             # paranoia: guard against cyclic reference
19 25         47 delete ${$self->[1]}->{$_} for keys %{${$self->[1]}};
  25         45  
  25         128  
  54         141  
20              
21 25         59 ${$self->[1]} = $self->[0];
  25         229  
22             }
23              
24             1;
25