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 5     5   33 use aliased 'MooseX::DIC::ContainerException';
  5         13  
  5         31  
8 5     5   2561 use Module::Load;
  5         5519  
  5         34  
9 5     5   251 use Try::Tiny;
  5         12  
  5         912  
10              
11             sub build_factory {
12 9     9 0 34 my ( $factory_type, $container ) = @_;
13              
14 9         23 my $service_factory;
15             try {
16 9     9   524 load "MooseX::DIC::ServiceFactory::$factory_type";
17              
18 9         835 $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 9         120 };
25              
26 9         234 return $service_factory;
27             }
28              
29             1;