line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Message::Passing::DSL::Factory; |
2
|
4
|
|
|
4
|
|
548
|
use Moo; |
|
4
|
|
|
|
|
12228
|
|
|
4
|
|
|
|
|
30
|
|
3
|
4
|
|
|
4
|
|
2852
|
use MooX::Types::MooseLike::Base qw/ HashRef /; |
|
4
|
|
|
|
|
4877
|
|
|
4
|
|
|
|
|
224
|
|
4
|
4
|
|
|
4
|
|
1963
|
use String::RewritePrefix; |
|
4
|
|
|
|
|
44707
|
|
|
4
|
|
|
|
|
28
|
|
5
|
4
|
|
|
4
|
|
2770
|
use Message::Passing::Output::STDERR; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
154
|
|
6
|
4
|
|
|
4
|
|
36
|
use Carp qw/ confess /; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
262
|
|
7
|
4
|
|
|
4
|
|
21
|
use Scalar::Util qw/ blessed /; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
171
|
|
8
|
4
|
|
|
4
|
|
52
|
use Module::Runtime qw/ require_module /; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
33
|
|
9
|
4
|
|
|
4
|
|
205
|
use namespace::clean -except => [qw/ meta _build_default_error_chain /]; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
36
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub expand_class_name { |
12
|
13
|
|
|
13
|
0
|
36
|
my ($self, $type, $name) = @_; |
13
|
13
|
|
|
|
|
266
|
String::RewritePrefix->rewrite({ |
14
|
|
|
|
|
|
|
'' => 'Message::Passing::' . $type . '::', |
15
|
|
|
|
|
|
|
'+' => '' |
16
|
|
|
|
|
|
|
}, $name); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has registry => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
isa => HashRef, |
22
|
|
|
|
|
|
|
default => sub { {} }, |
23
|
|
|
|
|
|
|
lazy => 1, |
24
|
|
|
|
|
|
|
clearer => 'clear_registry', |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
9
|
|
|
9
|
0
|
217
|
sub registry_get { shift->registry->{shift()} } |
28
|
13
|
|
|
13
|
0
|
321
|
sub registry_has { exists shift->registry->{shift()} } |
29
|
|
|
|
|
|
|
sub registry_set { |
30
|
13
|
|
|
13
|
0
|
33
|
my ($self, $name, $val) = @_; |
31
|
13
|
|
|
|
|
751
|
$self->registry->{$name} = $val; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub set_error { |
35
|
1
|
|
|
1
|
0
|
2
|
my ($self, %opts) = @_; |
36
|
1
|
|
33
|
|
|
5
|
my $class = delete $opts{class} |
37
|
|
|
|
|
|
|
|| confess("Class name needed"); |
38
|
1
|
|
|
|
|
4
|
require_module($class); |
39
|
1
|
|
|
|
|
45
|
$self->_set_error($class->new(%opts)); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
4
|
|
|
4
|
|
3641
|
use Message::Passing::Role::HasErrorChain; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1516
|
|
43
|
|
|
|
|
|
|
*_build_default_error_chain = \&Message::Passing::Role::HasErrorChain::_build_default_error_chain; |
44
|
|
|
|
|
|
|
has error => ( |
45
|
|
|
|
|
|
|
is => 'ro', |
46
|
|
|
|
|
|
|
writer => '_set_error', |
47
|
|
|
|
|
|
|
lazy => 1, |
48
|
|
|
|
|
|
|
builder => '_build_default_error_chain', |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub make { |
52
|
13
|
|
|
13
|
0
|
62
|
my ($self, %opts) = @_; |
53
|
13
|
|
33
|
|
|
64
|
my $class = delete $opts{class} |
54
|
|
|
|
|
|
|
|| confess("Class name needed"); |
55
|
13
|
|
|
|
|
38
|
my $name = delete $opts{name}; |
56
|
13
|
|
|
|
|
29
|
my $type = delete $opts{_type}; |
57
|
13
|
50
|
|
|
|
53
|
confess("We already have a thing named $name") |
58
|
|
|
|
|
|
|
if $self->registry_has($name); |
59
|
13
|
|
|
|
|
261
|
my $output_to = $opts{output_to}; |
60
|
13
|
100
|
66
|
|
|
103
|
if ($output_to && !blessed($output_to)) { |
61
|
|
|
|
|
|
|
# We have to deal with the ARRAY case here for Filter::T |
62
|
9
|
100
|
|
|
|
36
|
if (ref($output_to) eq 'ARRAY') { |
63
|
1
|
|
|
|
|
2
|
my @out; |
64
|
1
|
|
|
|
|
2
|
foreach my $name_or_thing (@$output_to) { |
65
|
1
|
50
|
|
|
|
3
|
if (blessed($name_or_thing)) { |
66
|
0
|
|
|
|
|
0
|
push(@out, $name_or_thing); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else { |
69
|
1
|
|
33
|
|
|
4
|
my $thing = $self->registry_get($name_or_thing) |
70
|
|
|
|
|
|
|
|| confess("Do not have a component named '$name_or_thing'"); |
71
|
1
|
|
|
|
|
10
|
push(@out, $thing); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
1
|
|
|
|
|
2
|
$opts{output_to} = \@out; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
else { |
77
|
8
|
|
33
|
|
|
35
|
my $proper_output_to = $self->registry_get($output_to) |
78
|
|
|
|
|
|
|
|| confess("Do not have a component named '$output_to'"); |
79
|
8
|
|
|
|
|
88
|
$opts{output_to} = $proper_output_to; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
13
|
50
|
|
|
|
50
|
if (!exists($opts{error})) { |
83
|
13
|
|
|
|
|
274
|
$opts{error} = $self->error; |
84
|
|
|
|
|
|
|
} |
85
|
13
|
|
|
|
|
385
|
$class = $self->expand_class_name($type, $class); |
86
|
13
|
|
|
|
|
1067
|
require_module($class); |
87
|
13
|
|
|
|
|
263
|
my $out = $class->new(%opts); |
88
|
13
|
|
|
|
|
8492
|
$self->registry_set($name, $out); |
89
|
13
|
|
|
|
|
245
|
return $out; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 NAME |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Message::Passing::DSL::Factory - Build a set of chains using symbolic names |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 DESCRIPTION |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
No user serviceable parts inside. See L. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SPONSORSHIP |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This module exists due to the wonderful people at Suretec Systems Ltd. |
106
|
|
|
|
|
|
|
who sponsored its development for its |
107
|
|
|
|
|
|
|
VoIP division called SureVoIP for use with |
108
|
|
|
|
|
|
|
the SureVoIP API - |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 AUTHOR, COPYRIGHT AND LICENSE |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
See L. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
116
|
|
|
|
|
|
|
|