File Coverage

lib/MooseX/DIC/ServiceFactoryFactory.pm
Criterion Covered Total %
statement 15 16 93.7
branch n/a
condition n/a
subroutine 5 6 83.3
pod 0 1 0.0
total 20 23 86.9


line stmt bran cond sub pod time code
1             package MooseX::DIC::ServiceFactoryFactory;
2              
3             require Exporter;
4             @ISA = qw/Exporter/;
5             @EXPORT_OK = qw/build_factory/;
6              
7 4     4   29 use aliased 'MooseX::DIC::ContainerException';
  4         10  
  4         28  
8 4     4   1933 use Module::Load;
  4         3708  
  4         26  
9 4     4   163 use Try::Tiny;
  4         47  
  4         617  
10              
11             sub build_factory {
12 8     8 0 27 my ( $factory_type, $container ) = @_;
13              
14 8         21 my $service_factory;
15             try {
16 8     8   364 load "MooseX::DIC::ServiceFactory::$factory_type";
17              
18 8         632 $service_factory = "MooseX::DIC::ServiceFactory::$factory_type"
19             ->new( container => $container );
20              
21             } catch {
22 0     0   0 ContainerException->throw(
23             message => "Could not build the service factory $factory_type: $_" );
24 8         110 };
25              
26 8         168 return $service_factory;
27             }
28              
29             1;