summaryrefslogtreecommitdiff
path: root/lib/Config/AST/Node/Null.pm
blob: 951f4ff47dc69c26d79fa3160068c77fcb0c49b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package Config::AST::Node::Null;
use parent 'Config::AST::Node';
use strict;
use warnings;
use Carp;

=head1 NAME

Config::AST::Node::Null - a null node    

=head1 DESCRIPTION

Implements null node - a node returned by direct retrieval if the requested
node is not present in the tree.    

In boolean context, null nodes evaluate to false.
    
=head1 METHODS

=head2 $node->is_null

Returns true.

=cut    
    
sub is_null { 1 }

our $AUTOLOAD;

sub AUTOLOAD {
    my $self = shift;
    my $key = $AUTOLOAD;
    $key =~ s/.*:://;
    if ($key =~ s/^([A-Z])(.*)/\l$1$2/) {
	return $self;
    }
    confess "Can't locate method $AUTOLOAD";
}

=head2 $node->as_string

Returns the string "(null)".

=cut    

sub as_string { '(null)' }

=head2 $node->value

Returns C<undef>.    

=cut

sub value { undef }

use overload
    '""' => \&value,
    bool => \&value,
    '0+' => \&value,
    fallback => 1;

=head1 SEE ALSO

B<Config::AST>,    
B<Config::AST::Node>.

=cut    

1;

Return to:

Send suggestions and report system problems to the System administrator.