File Coverage

blib/lib/Object/Lazy/Ref.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod 1 1 100.0
total 27 27 100.0


line stmt bran cond sub pod time code
1             package Object::Lazy::Ref; ## no critic (TidyCode)
2            
3 2     2   3794 use strict;
  2         5  
  2         71  
4 2     2   12 use warnings;
  2         5  
  2         94  
5            
6             our $VERSION = '0.12';
7            
8 2     2   12 use Carp qw(croak);
  2         3  
  2         234  
9            
10             my %register;
11            
12             BEGIN {
13 2     2   10 my $old_core_global_ref = *CORE::GLOBAL::ref;
14             *CORE::GLOBAL::ref = sub ($) {
15 10     10   7027 my $ref = shift;
16            
17             return
18             exists $register{$ref}
19             ? $register{$ref}
20 10 100       37 : do {
21 9         23 local *CORE::GLOBAL::ref = $old_core_global_ref;
22 9         38 ref $ref;
23             };
24             }
25 2         130 }
26            
27             sub register {
28 1     1 1 3 my $object = shift;
29            
30 1         3 $register{$object} = $object->{ref};
31            
32 1         3 return;
33             }
34            
35             # $Id$
36            
37             1;
38            
39             __END__