File Coverage

blib/lib/KiokuDB/LiveObjects/Guard.pm
Criterion Covered Total %
statement 22 22 100.0
branch 2 2 100.0
condition n/a
subroutine 8 8 100.0
pod 0 3 0.0
total 32 35 91.4


line stmt bran cond sub pod time code
1             package KiokuDB::LiveObjects::Guard;
2              
3 22     22   106 use strict;
  22         63  
  22         757  
4 22     22   96 use warnings;
  22         28  
  22         547  
5              
6 22     22   87 use Scalar::Util qw(weaken);
  22         31  
  22         943  
7              
8 22     22   104 use namespace::clean -except => 'meta';
  22         38  
  22         198  
9              
10             sub new {
11 8143     8143 0 11121 my ( $class, $hash, $key ) = @_;
12 8143         30894 my $self = bless [ $hash, $key ], $class;
13 8143         22734 weaken $self->[0];
14 8143         23138 return $self;
15             }
16              
17             sub key {
18 9865     9865 0 44168 $_[0][1];
19             }
20              
21             sub DESTROY {
22 8143     8143   17936 my $self = shift;
23 8143         14498 my ( $hash, $key ) = splice @$self;
24 8143 100       69214 delete $hash->{$key} if $hash;
25             }
26              
27             sub dismiss {
28 3     3 0 4 my $self = shift;
29 3         16 @$self = ();
30             }
31              
32              
33             __PACKAGE__
34              
35             __END__