File Coverage

blib/lib/Enbld/Target/AttributeCollector.pm
Criterion Covered Total %
statement 25 26 96.1
branch 4 4 100.0
condition n/a
subroutine 6 7 85.7
pod 0 2 0.0
total 35 39 89.7


line stmt bran cond sub pod time code
1             package Enbld::Target::AttributeCollector;
2              
3 20     20   11209 use strict;
  20         36  
  20         791  
4 20     20   94 use warnings;
  20         29  
  20         602  
5              
6 20     20   89 use Carp;
  20         27  
  20         6638  
7              
8             sub new {
9 176     176 0 21614 my $class = shift;
10              
11 176         762 return bless {}, $class;
12             }
13              
14             sub add {
15 1403     1403 0 3084 my ( $self, $name, $param ) = @_;
16              
17 1403 100       2756 if ( $self->{$name} ) {
18 1         5 require Enbld::Exception;
19 1         4 croak( Enbld::Exception->new( $name . " is already added" ) );
20             }
21              
22 1402         13492 require Enbld::Target::Attribute;
23 1402         3758 $self->{$name} = Enbld::Target::Attribute->new( $name, $param );
24 1384         4857 $self->{$name}->link_to_collector( $self );
25              
26 1384         2888 return $self;
27             }
28              
29             sub AUTOLOAD {
30 1510     1510   4329 my $self = shift;
31              
32 1510         2040 my $method = our $AUTOLOAD;
33 1510         6835 $method =~ s/.*:://;
34              
35 1510 100       9368 return $self->{$method}->to_value if ( exists $self->{$method} );
36              
37 1         522 require Enbld::Exception;
38 1         7 croak( Enbld::Exception->new( "'$method' is invalid method" ) );
39             }
40              
41 0     0     sub DESTROY {
42             # do nothing
43             }
44              
45             1;