line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::DI::Definition; |
2
|
4
|
|
|
4
|
|
56960
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
133
|
|
3
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
218
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use constant { |
6
|
4
|
|
|
|
|
3307
|
INJECTION_TYPES =>[ |
7
|
|
|
|
|
|
|
"setter","constructer", |
8
|
|
|
|
|
|
|
], |
9
|
|
|
|
|
|
|
INSTANCE_TYPES =>[ |
10
|
|
|
|
|
|
|
"singleton","prototype", |
11
|
|
|
|
|
|
|
], |
12
|
|
|
|
|
|
|
DEFAULT_INJECTION_TYPE => "setter", |
13
|
|
|
|
|
|
|
DEFAULT_INSTANCE_TYPE => "singleton", |
14
|
4
|
|
|
4
|
|
19
|
}; |
|
4
|
|
|
|
|
13
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new{ |
17
|
8
|
|
|
8
|
0
|
37
|
my $class = shift; |
18
|
8
|
|
|
|
|
12
|
my $resource = shift; |
19
|
8
|
|
|
|
|
48
|
my $self = { |
20
|
|
|
|
|
|
|
_name => undef, |
21
|
|
|
|
|
|
|
_class_name => undef, |
22
|
|
|
|
|
|
|
_properties => {}, |
23
|
|
|
|
|
|
|
_injection_type => DEFAULT_INJECTION_TYPE, |
24
|
|
|
|
|
|
|
_instance_type => DEFAULT_INSTANCE_TYPE, |
25
|
|
|
|
|
|
|
}; |
26
|
8
|
|
|
|
|
18
|
bless $self,$class; |
27
|
8
|
|
|
|
|
19
|
$self->initialize($resource); |
28
|
8
|
|
|
|
|
39
|
return $self; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub set_name{ |
32
|
8
|
|
|
8
|
0
|
9
|
my $self = shift; |
33
|
8
|
|
|
|
|
21
|
$self->{_name} = shift; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub set_class_name{ |
37
|
8
|
|
|
8
|
0
|
9
|
my $self = shift; |
38
|
8
|
|
|
|
|
12
|
$self->{_class_name} = shift; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub set_injection_type{ |
42
|
2
|
|
|
2
|
0
|
3
|
my $self = shift; |
43
|
2
|
|
|
|
|
5
|
$self->{_injection_type} = shift; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub set_instance_type{ |
47
|
2
|
|
|
2
|
0
|
3
|
my $self = shift; |
48
|
2
|
|
|
|
|
5
|
$self->{_instance_type} = shift; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub set_properties{ |
52
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
53
|
0
|
|
|
|
|
0
|
$self->{_properties} = shift; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub get_name{ |
58
|
1
|
|
|
1
|
0
|
6
|
my $self = shift; |
59
|
1
|
|
|
|
|
8
|
return $self->{_name}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub get_class_name{ |
63
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
64
|
1
|
|
|
|
|
6
|
return $self->{_class_name}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub get_injection_type{ |
68
|
1
|
|
|
1
|
0
|
22
|
my $self = shift; |
69
|
1
|
|
|
|
|
6
|
return $self->{_injection_type}; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
sub get_instance_type{ |
72
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
73
|
1
|
|
|
|
|
7
|
return $self->{_instance_type}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
sub get_properties{ |
76
|
14
|
|
|
14
|
0
|
27
|
my $self = shift; |
77
|
14
|
|
|
|
|
63
|
return $self->{_properties}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub initialize{ |
81
|
8
|
|
|
8
|
0
|
10
|
my $self = shift; |
82
|
8
|
|
|
|
|
9
|
my $resource = shift; |
83
|
8
|
|
|
|
|
25
|
$self->set_name($resource->{name}); |
84
|
8
|
|
|
|
|
22
|
$self->set_class_name($resource->{class_name}); |
85
|
|
|
|
|
|
|
|
86
|
8
|
100
|
|
|
|
21
|
if( exists $resource->{injection_type}){ |
87
|
2
|
|
|
|
|
8
|
$self->set_injection_type($resource->{injection_type}); |
88
|
|
|
|
|
|
|
} |
89
|
8
|
100
|
|
|
|
21
|
if( exists $resource->{instance_type}){ |
90
|
2
|
|
|
|
|
7
|
$self->set_instance_type($resource->{instance_type}); |
91
|
|
|
|
|
|
|
} |
92
|
8
|
|
|
|
|
8
|
foreach my $property_name (keys %{$resource->{properties}}){ |
|
8
|
|
|
|
|
26
|
|
93
|
12
|
|
|
|
|
20
|
my $property_value = $resource->{properties}->{$property_name}; |
94
|
12
|
|
|
|
|
23
|
$property_value = $self->evaluate_property($property_value); |
95
|
12
|
|
|
|
|
25
|
$self->get_properties->{$property_name} = $property_value; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub evaluate_property{ |
100
|
20
|
|
|
20
|
0
|
23
|
my $self = shift; |
101
|
20
|
|
|
|
|
25
|
my $property_value = shift; |
102
|
20
|
100
|
|
|
|
79
|
if(ref \$property_value eq "SCALAR"){ |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
103
|
12
|
|
|
|
|
31
|
return $property_value; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
elsif(ref $property_value eq "ARRAY"){ |
106
|
2
|
|
|
|
|
4
|
my @values = map { $self->evaluate_property($_) } @{$property_value}; |
|
5
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
5
|
|
107
|
2
|
|
|
|
|
6
|
return \@values; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
elsif(ref $property_value eq "HASH"){ |
110
|
6
|
100
|
|
|
|
13
|
if(exists $property_value->{class_name}){ |
111
|
3
|
|
|
|
|
9
|
return new Class::DI::Definition($property_value); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
else{ |
114
|
3
|
|
|
|
|
4
|
foreach my $key (keys %{$property_value}){ |
|
3
|
|
|
|
|
10
|
|
115
|
3
|
|
|
|
|
23
|
$property_value->{$key} = $self->evaluate_property($property_value->{$key}); |
116
|
|
|
|
|
|
|
} |
117
|
3
|
|
|
|
|
8
|
return $property_value; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
1; |