line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bolts::Inference; |
2
|
|
|
|
|
|
|
$Bolts::Inference::VERSION = '0.143171'; |
3
|
|
|
|
|
|
|
# ABSTRACT: This is the interface for inferring injectors from a blueprint |
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
2847
|
use Moose::Role; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
41
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
requires 'infer'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
1; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__END__ |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=pod |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=encoding UTF-8 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Bolts::Inference - This is the interface for inferring injectors from a blueprint |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 VERSION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
version 0.143171 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
package MyApp::Inference::Frobnicator; |
29
|
|
|
|
|
|
|
use Moose; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
with 'Bolts::Inference'; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub infer { |
34
|
|
|
|
|
|
|
my ($self, $blueprint) = @_; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
return unless $blueprint->ia('MyApp::Blueprint::Frobnicator'); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $type = $blueprint->type_of_thingamajig; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my @parameters; |
41
|
|
|
|
|
|
|
if ($type eq 'foo') { |
42
|
|
|
|
|
|
|
push @parameters, { |
43
|
|
|
|
|
|
|
key => 'foo', |
44
|
|
|
|
|
|
|
inject_via => [ 'injector, 'setter' ], |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
push @parameters, { |
47
|
|
|
|
|
|
|
key => 'bar', |
48
|
|
|
|
|
|
|
inject_via => [ 'injector', 'parameter_name' ], |
49
|
|
|
|
|
|
|
}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
elsif ($type eq 'bar') { |
52
|
|
|
|
|
|
|
push @parameters, { |
53
|
|
|
|
|
|
|
key => 'bar', |
54
|
|
|
|
|
|
|
inject_via => [ 'injector', 'setter' ], |
55
|
|
|
|
|
|
|
}; |
56
|
|
|
|
|
|
|
push @parameters, { |
57
|
|
|
|
|
|
|
key => 'foo', |
58
|
|
|
|
|
|
|
inject_via => [ 'injector', 'parameter_name' ], |
59
|
|
|
|
|
|
|
}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
else { |
62
|
|
|
|
|
|
|
die "cannot infer from type [$type]"; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 DESCRIPTION |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Defines the interface for Bolts inferrers. An inferrer is an object that is able |
69
|
|
|
|
|
|
|
to examine a blueprint and from that blueprint determine what parameters, |
70
|
|
|
|
|
|
|
settings, etc. the artifact constructed by the blueprint needs or may accept. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 REQUIRED METHODS |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 infer |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my @parameters = $inferrer->infer($blueprint); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Given a blueprint, this must return a list of parameter descriptions, which are returned as a hash. Each element may contain the following keys: |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=over |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item key |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This is the name to give the parameter for injection. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item inject_via |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This is the full path to the injector to qcquire, found within the meta locator, usually L<Bolts::Meta::Locator>, usually under the "injector" key. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item isa |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This is the type constraint the injected value must adhere to. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item does |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This is the role type the injected value must adhere to. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item required |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This stats whether or not the parameter is required to complete the blueprint or not. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=back |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Notice that the blueprint is not determined by the inferer. This is handled by L<Bolts::Artifact> instead, via the L<Bolts::Artifact/infer> setting on the artifact in question. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Andrew Sterling Hanenkamp <hanenkamp@cpan.org> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Qubling Software LLC. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
115
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |