File Coverage

blib/lib/DBM/Deep/Null.pm
Criterion Covered Total %
statement 17 21 80.9
branch 1 4 25.0
condition 1 3 33.3
subroutine 8 11 72.7
pod n/a
total 27 39 69.2


line stmt bran cond sub pod time code
1             package DBM::Deep::Null;
2              
3 50     50   859 use 5.008_004;
  50         162  
4              
5 50     50   260 use strict;
  50         147  
  50         1381  
6 50     50   260 use warnings FATAL => 'all';
  50         100  
  50         10546  
7              
8             =head1 NAME
9              
10             DBM::Deep::Null - NULL object
11              
12             =head1 PURPOSE
13              
14             This is an internal-use-only object for L. It acts as a NULL object
15             in the same vein as MARCEL's L. I couldn't use L
16             because DBM::Deep needed an object that always evaluated as undef, not an
17             implementation of the Null Class pattern.
18              
19             =head1 OVERVIEW
20              
21             It is used to represent null sectors in DBM::Deep.
22              
23             =cut
24              
25             use overload
26 0     0   0 'bool' => sub { undef },
27 0     0   0 '""' => sub { undef },
28 0     0   0 '0+' => sub { 0 },
29             ('cmp' =>
30             '<=>' => sub {
31 2 50 33 2   687 return 0 if !defined $_[1] || !length $_[1];
32 0 0       0 return $_[2] ? 1 : -1;
33             }
34             )[0,2,1,2], # same sub for both ops
35             '%{}' => sub {
36 1     1   405 require Carp;
37 1         200 Carp::croak("Can't use a stale reference as a HASH");
38             },
39             '@{}' => sub {
40 1     1   828 require Carp;
41 1         74 Carp::croak("Can't use a stale reference as an ARRAY");
42             },
43 50         1035 fallback => 1,
44 50     50   406 nomethod => 'AUTOLOAD';
  50         126  
45              
46 2     2   734 sub AUTOLOAD { return; }
47              
48             1;
49             __END__