| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Dancer2::Core::Factory; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Instantiate components by type and name |
|
3
|
|
|
|
|
|
|
$Dancer2::Core::Factory::VERSION = '2.0.1'; |
|
4
|
165
|
|
|
165
|
|
682308
|
use Moo; |
|
|
165
|
|
|
|
|
29525
|
|
|
|
165
|
|
|
|
|
1471
|
|
|
5
|
165
|
|
|
165
|
|
86429
|
use Dancer2::Core; |
|
|
165
|
|
|
|
|
622
|
|
|
|
165
|
|
|
|
|
6468
|
|
|
6
|
165
|
|
|
165
|
|
2293
|
use Module::Runtime 'use_module'; |
|
|
165
|
|
|
|
|
5459
|
|
|
|
165
|
|
|
|
|
1115
|
|
|
7
|
165
|
|
|
165
|
|
9297
|
use Carp 'croak'; |
|
|
165
|
|
|
|
|
382
|
|
|
|
165
|
|
|
|
|
37474
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub create { |
|
10
|
804
|
|
|
804
|
0
|
56213
|
my ( $class, $type, $name, %options ) = @_; |
|
11
|
|
|
|
|
|
|
|
|
12
|
804
|
|
|
|
|
4121
|
$type = Dancer2::Core::camelize($type); |
|
13
|
804
|
|
|
|
|
2357
|
$name = Dancer2::Core::camelize($name); |
|
14
|
804
|
|
|
|
|
2267
|
my $component_class = "Dancer2::${type}::${name}"; |
|
15
|
|
|
|
|
|
|
|
|
16
|
804
|
100
|
|
|
|
1794
|
eval { use_module($component_class); 1; } |
|
|
804
|
|
|
|
|
4184
|
|
|
|
803
|
|
|
|
|
53833
|
|
|
17
|
|
|
|
|
|
|
or croak "Unable to load class for $type component $name: $@"; |
|
18
|
|
|
|
|
|
|
|
|
19
|
803
|
|
|
|
|
13692
|
return $component_class->new(%options); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
1; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__END__ |