blib/lib/WebDAO/Lexer/base.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 55 CC 5 SCAR 17.6
CC
5
Cov
0%
value
12.0
new
6.0
childs
6.0
CRAP 5.8
1 package WebDAO::Lexer::base;
2 use strict;
3 use warnings;
4 use Data::Dumper;
5  
6 =head1 NAME
7  
8 WebDAO::Lexer::base - Base class
9  
10 =head1 SYNOPSIS
11  
12 =head1 DESCRIPTION
13  
14 WebDAO::Lexer::base - Base class
15  
16 =cut
17  
18 our $VERSION = '0.01';
19  
20 sub new {
21 my $class = shift;
22 bless( $#_ == 0 ? {shift} : {@_}, ref($class) || $class );
23 }
24  
25 sub childs {
26 my $self = shift;
27 return ()
28 unless ( exists $self->{childs} );
29 @{ $self->{childs} };
30 }
31  
32 sub name {
33 my $self = shift;
34 $self->{name};
35 }
36  
37 sub attr {
38 my $self = shift;
39 $self->{attr}
40 }
41  
42 sub value {
43 my $self = shift;
44 my @res = ();
45  
46 #allow anly objects
47 foreach my $c ( $self->childs ) {
48 unless ( UNIVERSAL::isa( $c, 'WebDAO::Lexer::object' ) ) {
49 print "Bad element at " . Dumper($c);
50 next;
51 }
52 push @res, $c->value(@_);
53 }
54 return ( $self->name => scalar(@res) > 1 ? \@res : $res[0] );
55 }
56  
57 1;
58 __DATA__
59  
60 =head1 SEE ALSO
61  
62 http://sourceforge.net/projects/webdao
63  
64 =head1 AUTHOR
65  
66 Zahatski Aliaksandr, E<lt>zag@cpan.orgE<gt>
67  
68 =head1 COPYRIGHT AND LICENSE
69  
70 Copyright 2002-2011 by Zahatski Aliaksandr
71  
72 This library is free software; you can redistribute it and/or modify
73 it under the same terms as Perl itself.
74  
75 =cut
76  
77