File Coverage

blib/lib/IOC/Container/MethodResolution.pm
Criterion Covered Total %
statement 19 19 100.0
branch 6 6 100.0
condition n/a
subroutine 5 5 100.0
pod n/a
total 30 30 100.0


line stmt bran cond sub pod time code
1              
2             package IOC::Container::MethodResolution;
3              
4 4     4   75171 use strict;
  4         10  
  4         164  
5 4     4   22 use warnings;
  4         9  
  4         249  
6              
7             our $VERSION = '0.02';
8              
9 4     4   637 use IOC::Exceptions;
  4         10  
  4         192  
10              
11 4     4   70 use base 'IOC::Container';
  4         9  
  4         7712  
12              
13             our $AUTOLOAD;
14              
15             sub AUTOLOAD {
16 6     6   163 my ($self) = @_;
17 6         23 my $name = (split '::', $AUTOLOAD)[-1];
18 6 100       37 if ($name eq 'root') {
    100          
    100          
19 1         9 return $self->findRootContainer();
20             }
21             elsif ($self->hasService($name)) {
22 3         17 return $self->get($name);
23             }
24             elsif ($self->hasSubContainer($name)) {
25 1         7 return $self->getSubContainer($name);
26             }
27 1         17 throw IOC::NotFound "Could not find either a service or a sub-container named '$name'";
28             }
29              
30             1;
31              
32             __END__