line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
3
|
|
|
3
|
|
28
|
use v5.10; |
|
3
|
|
|
|
|
8
|
|
3
|
3
|
|
|
3
|
|
15
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
55
|
|
4
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
61
|
|
5
|
3
|
|
|
3
|
|
13
|
use feature 'state'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
272
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Context::Singleton::Frame::DB; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = v1.0.5; |
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
1174
|
use Class::Load; |
|
3
|
|
|
|
|
38650
|
|
|
3
|
|
|
|
|
112
|
|
12
|
3
|
|
|
3
|
|
1155
|
use Module::Pluggable::Object; |
|
3
|
|
|
|
|
17869
|
|
|
3
|
|
|
|
|
81
|
|
13
|
3
|
|
|
3
|
|
390
|
use Ref::Util; |
|
3
|
|
|
|
|
1264
|
|
|
3
|
|
|
|
|
101
|
|
14
|
|
|
|
|
|
|
|
15
|
3
|
|
|
3
|
|
1079
|
use Context::Singleton::Frame::Builder::Value; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
99
|
|
16
|
3
|
|
|
3
|
|
1023
|
use Context::Singleton::Frame::Builder::Hash; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
68
|
|
17
|
3
|
|
|
3
|
|
962
|
use Context::Singleton::Frame::Builder::Array; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1794
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
37
|
|
|
37
|
0
|
64
|
my ($class) = @_; |
21
|
|
|
|
|
|
|
|
22
|
37
|
|
|
|
|
101
|
my $self = bless { |
23
|
|
|
|
|
|
|
cache => {}, |
24
|
|
|
|
|
|
|
plugin => {}, |
25
|
|
|
|
|
|
|
}, $class; |
26
|
|
|
|
|
|
|
|
27
|
37
|
|
|
|
|
94
|
$self->contrive ('Class::Load', ( |
28
|
|
|
|
|
|
|
value => 'Class::Load', |
29
|
|
|
|
|
|
|
)); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$self->contrive ('class_loader', ( |
32
|
|
|
|
|
|
|
dep => [ 'Class::Load' ], |
33
|
0
|
|
|
0
|
|
0
|
as => sub { $_[0]->can ('load_class') }, |
34
|
37
|
|
|
|
|
182
|
)); |
35
|
|
|
|
|
|
|
|
36
|
37
|
|
|
|
|
112
|
return $self; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub instance { |
40
|
73
|
|
|
73
|
0
|
8884
|
state $instance = __PACKAGE__->new; |
41
|
73
|
|
|
|
|
186
|
return $instance; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub _contrive_class_loader { |
45
|
1
|
|
|
1
|
|
3
|
my ($self, $name) = @_; |
46
|
|
|
|
|
|
|
|
47
|
1
|
50
|
|
|
|
4
|
return if exists $self->{cache}{$name}; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
81
|
$self->contrive ($name, ( |
50
|
|
|
|
|
|
|
dep => [ 'class_loader' ], |
51
|
|
|
|
|
|
|
as => eval "sub { \$_[0]->(q[$name]) && q[$name] }", |
52
|
|
|
|
|
|
|
)); |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
3
|
return; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _guess_builder_class { |
58
|
318
|
|
|
318
|
|
441
|
my ($self, $def) = @_; |
59
|
|
|
|
|
|
|
|
60
|
318
|
100
|
|
|
|
517
|
return 'Context::Singleton::Frame::Builder::Value' if exists $def->{value}; |
61
|
244
|
50
|
|
|
|
381
|
return 'Context::Singleton::Frame::Builder::Hash' if Ref::Util::is_hashref ($def->{dep}); |
62
|
244
|
|
|
|
|
357
|
return 'Context::Singleton::Frame::Builder::Array' |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub contrive { |
66
|
318
|
|
|
318
|
0
|
615
|
my ($self, $name, %def) = @_; |
67
|
|
|
|
|
|
|
|
68
|
318
|
100
|
|
|
|
546
|
if ($def{class}) { |
69
|
1
|
|
|
|
|
4
|
$self->_contrive_class_loader ($def{class}); |
70
|
1
|
|
50
|
|
|
5
|
$def{builder} //= 'new'; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
318
|
100
|
66
|
|
|
895
|
if ($def{class} // $def{deduce}) { |
74
|
1
|
|
33
|
|
|
3
|
$def{this} = $def{class} // $def{deduce}; |
75
|
1
|
|
|
|
|
3
|
delete $def{class}; |
76
|
1
|
|
|
|
|
2
|
delete $def{deduce}; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
318
|
|
|
|
|
463
|
my $builder_class = $self->_guess_builder_class (\%def); |
80
|
318
|
|
|
|
|
836
|
my $builder = $builder_class->new (%def); |
81
|
|
|
|
|
|
|
|
82
|
318
|
|
|
|
|
404
|
push @{ $self->{cache}{ $name } }, $builder; |
|
318
|
|
|
|
|
718
|
|
83
|
|
|
|
|
|
|
|
84
|
318
|
|
|
|
|
736
|
return; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub trigger { |
88
|
34
|
|
|
34
|
0
|
78
|
my ($self, $name, $code) = @_; |
89
|
|
|
|
|
|
|
|
90
|
34
|
|
|
|
|
42
|
push @{ $self->{trigger}{ $name } }, $code; |
|
34
|
|
|
|
|
105
|
|
91
|
|
|
|
|
|
|
|
92
|
34
|
|
|
|
|
73
|
return; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub find_builder_for { |
96
|
95
|
|
|
95
|
0
|
168
|
my ($self, $name) = @_; |
97
|
|
|
|
|
|
|
|
98
|
95
|
|
100
|
|
|
106
|
return @{ $self->{cache}{ $name } // [] }; |
|
95
|
|
|
|
|
350
|
|
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub find_trigger_for { |
102
|
30
|
|
|
30
|
0
|
47
|
my ($self, $name) = @_; |
103
|
|
|
|
|
|
|
|
104
|
30
|
|
100
|
|
|
36
|
return @{ $self->{trigger}{ $name } // [] }; |
|
30
|
|
|
|
|
128
|
|
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub load_rules { |
108
|
6
|
|
|
6
|
0
|
15
|
my ($self, @packages) = @_; |
109
|
|
|
|
|
|
|
|
110
|
6
|
|
|
|
|
11
|
for my $package (@packages) { |
111
|
6
|
|
66
|
|
|
19
|
$self->{plugins}{ $package } //= do { |
112
|
5
|
|
|
|
|
29
|
Module::Pluggable::Object->new ( |
113
|
|
|
|
|
|
|
require => 1, |
114
|
|
|
|
|
|
|
search_path => [ $package ], |
115
|
|
|
|
|
|
|
)->plugins; |
116
|
5
|
|
|
|
|
6152
|
1; |
117
|
|
|
|
|
|
|
}; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
6
|
|
|
|
|
1906
|
return; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |