lib/Dancer2/Core/Factory.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 96.9% 32 / 33 CC 3 SCAR 6.2
CC
3
Cov
100%
create
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« lib/Dancer2/Core/Request/Upload.pm ↑ Summary lib/Dancer2/Core/Role/HasConfig.pm »
1 package Dancer2::Core::Factory;
2 # ABSTRACT: Instantiate components by type and name
3 196 $Dancer2::Core::Factory::VERSION = '2.3.0';
4 196 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 196 ▶use Dancer2::Core;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 196 ▶use Module::Runtime 'use_module';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 196 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 977 ▶sub create {
Subroutine create: called CC=3 SCAR=11.0
Pod undocumented
10 977 my ( $class, $type, $name, %options ) = @_;
11  
12 977 $type = Dancer2::Core::camelize($type);
13 977 $name = Dancer2::Core::camelize($name);
14 977 my $was_fully_qualified = ( $name =~ s/^\+// ); # strip any leading '+'
15 977 ▶ my $component_class = ( $was_fully_qualified ) ? $name : "Dancer2::${type}::${name}";
Branch: 1 branch
BranchTrueFalseTotal
$was_fully_qualified ? : 1 976 977
16  
17 977 ▶ eval { use_module($component_class); 1; }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { &use_module($component_class); 1 } } or croak("Unable to load class for $type component ${name}: $@") 976 1 977
18 or croak "Unable to load class for $type component $name: $@";
19  
20 976 return $component_class->new(%options);
21 }
22  
23 196 1;
24  
25 __END__
« lib/Dancer2/Core/Request/Upload.pm ↑ Summary lib/Dancer2/Core/Role/HasConfig.pm »