line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::DI; |
2
|
2
|
|
|
2
|
|
94036
|
use 5.008008; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
72
|
|
3
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
59
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
96
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
7
|
2
|
|
|
2
|
|
1001
|
use Class::DI::Definition; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
52
|
|
8
|
2
|
|
|
2
|
|
1096
|
use Class::DI::Resource::YAML; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Class::DI::Factory; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new{ |
12
|
|
|
|
|
|
|
my $class = shift; |
13
|
|
|
|
|
|
|
my $resource = shift; |
14
|
|
|
|
|
|
|
my $self = { |
15
|
|
|
|
|
|
|
_resource => $resource, |
16
|
|
|
|
|
|
|
_factory => Class::DI::Factory->new, |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
bless $self,$class; |
19
|
|
|
|
|
|
|
return $self; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub yaml_container{ |
23
|
|
|
|
|
|
|
my $class = shift; |
24
|
|
|
|
|
|
|
my $file_path = shift; |
25
|
|
|
|
|
|
|
my $resource = Class::DI::Resource::YAML->new($file_path); |
26
|
|
|
|
|
|
|
return $class->new($resource); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub get_component{ |
30
|
|
|
|
|
|
|
my $self = shift; |
31
|
|
|
|
|
|
|
my $id = shift; |
32
|
|
|
|
|
|
|
my $resource = $self->{_resource}->get_resource($id); |
33
|
|
|
|
|
|
|
die "not found definition id:$id" unless($resource); |
34
|
|
|
|
|
|
|
my $definition = Class::DI::Definition->new($resource); |
35
|
|
|
|
|
|
|
my $instance = $self->{_factory}->get_instance($definition); |
36
|
|
|
|
|
|
|
return $instance; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
__END__ |