File Coverage

lib/Config/AST/Node/Null.pm
Criterion Covered Total %
statement 17 24 70.8
branch 0 2 0.0
condition n/a
subroutine 7 10 70.0
pod 3 3 100.0
total 27 39 69.2


line stmt bran cond sub pod time code
1             # This file is part of Config::AST -*- perl -*-
2             # Copyright (C) 2017-2019 Sergey Poznyakoff
3             #
4             # Config::AST is free software; you can redistribute it and/or modify
5             # it under the terms of the GNU General Public License as published by
6             # the Free Software Foundation; either version 3, or (at your option)
7             # any later version.
8             #
9             # Config::AST is distributed in the hope that it will be useful,
10             # but WITHOUT ANY WARRANTY; without even the implied warranty of
11             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12             # GNU General Public License for more details.
13             #
14             # You should have received a copy of the GNU General Public License
15             # along with Config::AST. If not, see .
16              
17             package Config::AST::Node::Null;
18 19     19   120 use parent 'Config::AST::Node';
  19         28  
  19         96  
19 19     19   1088 use strict;
  19         33  
  19         329  
20 19     19   78 use warnings;
  19         189  
  19         655  
21 19     19   356 use Carp;
  19         70  
  19         5559  
22              
23             =head1 NAME
24              
25             Config::AST::Node::Null - a null node
26              
27             =head1 DESCRIPTION
28              
29             Implements null node - a node returned by direct retrieval if the requested
30             node is not present in the tree.
31              
32             In boolean context, null nodes evaluate to false.
33            
34             =head1 METHODS
35              
36             =head2 $node->is_null
37              
38             Returns true.
39              
40             =cut
41            
42 4     4 1 29 sub is_null { 1 }
43              
44             our $AUTOLOAD;
45              
46             sub AUTOLOAD {
47 0     0   0 my $self = shift;
48 0         0 my $key = $AUTOLOAD;
49 0         0 $key =~ s/.*:://;
50 0 0       0 if ($key =~ s/^([A-Z])(.*)/\l$1$2/) {
51 0         0 return $self;
52             }
53 0         0 confess "Can't locate method $AUTOLOAD";
54             }
55              
56       0     sub DESTROY { }
57              
58             =head2 $node->as_string
59              
60             Returns the string "(null)".
61              
62             =cut
63              
64 0     0 1 0 sub as_string { '(null)' }
65              
66             =head2 $node->value
67              
68             Returns C.
69              
70             =cut
71              
72 2     2 1 6 sub value { undef }
73              
74             use overload
75 19         119 '""' => \&value,
76             bool => \&value,
77             '0+' => \&value,
78 19     19   138 fallback => 1;
  19         31  
79              
80             =head1 SEE ALSO
81              
82             L,
83             L.
84              
85             =cut
86              
87             1;