File Coverage

blib/lib/DBR/Config/Table/Anon.pm
Criterion Covered Total %
statement 19 26 73.0
branch 3 8 37.5
condition 1 2 50.0
subroutine 5 11 45.4
pod 0 9 0.0
total 28 56 50.0


line stmt bran cond sub pod time code
1             # the contents of this file are Copyright (c) 2009 Daniel Norman
2             # This program is free software; you can redistribute it and/or
3             # modify it under the terms of the GNU General Public License as
4             # published by the Free Software Foundation.
5              
6             package DBR::Config::Table::Anon;
7              
8 18     18   105 use strict;
  18         38  
  18         788  
9 18     18   106 use base 'DBR::Config::Table::Common';
  18         40  
  18         10596  
10              
11 0     0 0 0 sub get_field { undef }
12 0     0 0 0 sub fields { [] }
13 494     494 0 5306 sub req_fields { [] }
14 0     0 0 0 sub primary_key { undef }
15              
16 0     0 0 0 sub get_relation { undef }
17 0     0 0 0 sub relations { [] }
18 0     0 0 0 sub conf_instance { undef }
19              
20             sub new{
21 1039     1039 0 2353 my( $package ) = shift;
22 1039         4524 my %params = @_;
23              
24 1039         3654 my $self = {
25             session => $params{session}
26             };
27              
28 1039         5626 bless( $self, $package );
29              
30 1039 50       4533 my $name = $params{name} or return $self->_error('name is required');
31 1039         3323 my $alias = $params{alias};
32              
33 1039 50       7814 return $self->_error("invalid name '$name'") unless $name =~ /^[A-Z][A-Z0-9_-]*$/i;
34              
35 1039 50       5373 if(defined($alias)){
36 0 0       0 return $self->_error("invalid alias '$alias'") unless $alias =~ /^[A-Z][A-Z0-9_-]*$/i;
37             }
38              
39 1039         2576 $self->{name} = $name;
40 1039   50     6739 $self->{alias} = $alias || '';
41              
42 1039         6931 return $self;
43             }
44              
45 2078     2078 0 9608 sub name { $_[0]->{name} }
46              
47             1;
48              
49             1;