| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Message::Passing::DSL::Factory; |
|
2
|
4
|
|
|
4
|
|
905
|
use Moo; |
|
|
4
|
|
|
|
|
19622
|
|
|
|
4
|
|
|
|
|
32
|
|
|
3
|
4
|
|
|
4
|
|
4281
|
use MooX::Types::MooseLike::Base qw/ HashRef /; |
|
|
4
|
|
|
|
|
13223
|
|
|
|
4
|
|
|
|
|
265
|
|
|
4
|
4
|
|
|
4
|
|
3655
|
use String::RewritePrefix; |
|
|
4
|
|
|
|
|
65082
|
|
|
|
4
|
|
|
|
|
32
|
|
|
5
|
4
|
|
|
4
|
|
3893
|
use Message::Passing::Output::STDERR; |
|
|
4
|
|
|
|
|
18
|
|
|
|
4
|
|
|
|
|
153
|
|
|
6
|
4
|
|
|
4
|
|
41
|
use Carp qw/ confess /; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
260
|
|
|
7
|
4
|
|
|
4
|
|
24
|
use Scalar::Util qw/ blessed /; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
180
|
|
|
8
|
4
|
|
|
4
|
|
71
|
use Module::Runtime qw/ require_module /; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
33
|
|
|
9
|
4
|
|
|
4
|
|
210
|
use namespace::clean -except => [qw/ meta _build_default_error_chain /]; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
42
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub expand_class_name { |
|
12
|
13
|
|
|
13
|
0
|
32
|
my ($self, $type, $name) = @_; |
|
13
|
13
|
|
|
|
|
131
|
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
|
185
|
sub registry_get { shift->registry->{shift()} } |
|
28
|
13
|
|
|
13
|
0
|
292
|
sub registry_has { exists shift->registry->{shift()} } |
|
29
|
|
|
|
|
|
|
sub registry_set { |
|
30
|
13
|
|
|
13
|
0
|
33
|
my ($self, $name, $val) = @_; |
|
31
|
13
|
|
|
|
|
300
|
$self->registry->{$name} = $val; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub set_error { |
|
35
|
1
|
|
|
1
|
0
|
4
|
my ($self, %opts) = @_; |
|
36
|
1
|
|
33
|
|
|
4
|
my $class = delete $opts{class} |
|
37
|
|
|
|
|
|
|
|| confess("Class name needed"); |
|
38
|
1
|
|
|
|
|
5
|
require_module($class); |
|
39
|
1
|
|
|
|
|
39
|
$self->_set_error($class->new(%opts)); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
4
|
|
|
4
|
|
4683
|
use Message::Passing::Role::HasErrorChain; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
1796
|
|
|
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
|
57
|
my ($self, %opts) = @_; |
|
53
|
13
|
|
33
|
|
|
63
|
my $class = delete $opts{class} |
|
54
|
|
|
|
|
|
|
|| confess("Class name needed"); |
|
55
|
13
|
|
|
|
|
25
|
my $name = delete $opts{name}; |
|
56
|
13
|
|
|
|
|
28
|
my $type = delete $opts{_type}; |
|
57
|
13
|
50
|
|
|
|
47
|
confess("We already have a thing named $name") |
|
58
|
|
|
|
|
|
|
if $self->registry_has($name); |
|
59
|
13
|
|
|
|
|
236
|
my $output_to = $opts{output_to}; |
|
60
|
13
|
100
|
66
|
|
|
91
|
if ($output_to && !blessed($output_to)) { |
|
61
|
|
|
|
|
|
|
# We have to deal with the ARRAY case here for Filter::T |
|
62
|
9
|
100
|
|
|
|
30
|
if (ref($output_to) eq 'ARRAY') { |
|
63
|
1
|
|
|
|
|
2
|
my @out; |
|
64
|
1
|
|
|
|
|
3
|
foreach my $name_or_thing (@$output_to) { |
|
65
|
1
|
50
|
|
|
|
4
|
if (blessed($name_or_thing)) { |
|
66
|
0
|
|
|
|
|
0
|
push(@out, $name_or_thing); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
else { |
|
69
|
1
|
|
33
|
|
|
7
|
my $thing = $self->registry_get($name_or_thing) |
|
70
|
|
|
|
|
|
|
|| confess("Do not have a component named '$name_or_thing'"); |
|
71
|
1
|
|
|
|
|
13
|
push(@out, $thing); |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
} |
|
74
|
1
|
|
|
|
|
3
|
$opts{output_to} = \@out; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
else { |
|
77
|
8
|
|
33
|
|
|
26
|
my $proper_output_to = $self->registry_get($output_to) |
|
78
|
|
|
|
|
|
|
|| confess("Do not have a component named '$output_to'"); |
|
79
|
8
|
|
|
|
|
83
|
$opts{output_to} = $proper_output_to; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
13
|
50
|
|
|
|
49
|
if (!exists($opts{error})) { |
|
83
|
13
|
|
|
|
|
255
|
$opts{error} = $self->error; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
13
|
|
|
|
|
253
|
$class = $self->expand_class_name($type, $class); |
|
86
|
13
|
|
|
|
|
830
|
require_module($class); |
|
87
|
13
|
|
|
|
|
206
|
my $out = $class->new(%opts); |
|
88
|
13
|
|
|
|
|
16281
|
$self->registry_set($name, $out); |
|
89
|
13
|
|
|
|
|
194
|
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
|
|
|
|
|
|
|
|