File Coverage

blib/lib/EJS/Template/Base.pm
Criterion Covered Total %
statement 20 21 95.2
branch 2 4 50.0
condition 1 2 50.0
subroutine 6 6 100.0
pod 2 2 100.0
total 31 35 88.5


line stmt bran cond sub pod time code
1 8     8   100 use 5.006;
  8         17  
2 8     8   26 use strict;
  8         9  
  8         120  
3 8     8   21 use warnings;
  8         7  
  8         226  
4              
5             =head1 NAME
6              
7             EJS::Template::Base - Base class for some EJS::Template classes to hold common config
8              
9             =cut
10              
11             package EJS::Template::Base;
12              
13 8     8   24 use Scalar::Util qw(reftype);
  8         9  
  8         1340  
14              
15             =head1 Methods
16              
17             =head2 new
18              
19             Common constructor with the config
20              
21             =cut
22              
23             sub new {
24 270     270 1 285 my ($class, $config) = @_;
25 270 50       490 $config = {} unless ref $config;
26 270         1244 return bless {config => $config}, $class;
27             }
28              
29             =head2 config
30              
31             Retrieves the config value.
32              
33             =cut
34              
35             sub config {
36 164     164 1 188 my $self = shift;
37 164         184 my $config = $self->{config};
38            
39 164         278 for my $name (@_) {
40 82 50 50     327 if ((reftype($config) || '') eq 'HASH') {
41 82         157 $config = $config->{$name};
42             } else {
43 0         0 return undef;
44             }
45             }
46            
47 164         832 return $config;
48             }
49              
50             =head1 SEE ALSO
51              
52             =over 4
53              
54             =item * L
55              
56             =back
57              
58             =cut
59              
60             1;