line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Declare::Context::Parameterized; |
2
|
|
|
|
|
|
|
# ABSTRACT: context for parsing optionally parameterized statements |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.43'; |
5
|
|
|
|
|
|
|
|
6
|
24
|
|
|
24
|
|
11533
|
use Moose::Role; |
|
24
|
|
|
|
|
36
|
|
|
24
|
|
|
|
|
147
|
|
7
|
24
|
|
|
24
|
|
84564
|
use MooseX::Types::Moose qw/Str HashRef/; |
|
24
|
|
|
|
|
41
|
|
|
24
|
|
|
|
|
168
|
|
8
|
|
|
|
|
|
|
|
9
|
24
|
|
|
24
|
|
79269
|
use namespace::autoclean; |
|
24
|
|
|
|
|
35
|
|
|
24
|
|
|
|
|
170
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
12
|
|
|
|
|
|
|
#pod |
13
|
|
|
|
|
|
|
#pod This context trait will add optional parameterization functionality to the |
14
|
|
|
|
|
|
|
#pod context. |
15
|
|
|
|
|
|
|
#pod |
16
|
|
|
|
|
|
|
#pod =attr parameter_signature |
17
|
|
|
|
|
|
|
#pod |
18
|
|
|
|
|
|
|
#pod This will be set when the C<strip_parameter_signature> method is called and it |
19
|
|
|
|
|
|
|
#pod was able to extract a list of parameterisations. |
20
|
|
|
|
|
|
|
#pod |
21
|
|
|
|
|
|
|
#pod =method has_parameter_signature |
22
|
|
|
|
|
|
|
#pod |
23
|
|
|
|
|
|
|
#pod Predicate method for the C<parameter_signature> attribute. |
24
|
|
|
|
|
|
|
#pod |
25
|
|
|
|
|
|
|
#pod =cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has parameter_signature => ( |
28
|
|
|
|
|
|
|
is => 'rw', |
29
|
|
|
|
|
|
|
isa => Str, |
30
|
|
|
|
|
|
|
predicate => 'has_parameter_signature', |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#pod =method add_parameter |
34
|
|
|
|
|
|
|
#pod |
35
|
|
|
|
|
|
|
#pod Allows storing parameters extracted from C<parameter_signature> to be used |
36
|
|
|
|
|
|
|
#pod later on. |
37
|
|
|
|
|
|
|
#pod |
38
|
|
|
|
|
|
|
#pod =method get_parameters |
39
|
|
|
|
|
|
|
#pod |
40
|
|
|
|
|
|
|
#pod Returns all previously added parameters. |
41
|
|
|
|
|
|
|
#pod |
42
|
|
|
|
|
|
|
#pod =cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has parameters => ( |
45
|
|
|
|
|
|
|
traits => ['Hash'], |
46
|
|
|
|
|
|
|
isa => HashRef, |
47
|
|
|
|
|
|
|
default => sub { {} }, |
48
|
|
|
|
|
|
|
handles => { |
49
|
|
|
|
|
|
|
add_parameter => 'set', |
50
|
|
|
|
|
|
|
get_parameters => 'kv', |
51
|
|
|
|
|
|
|
}, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
#pod =method strip_parameter_signature |
55
|
|
|
|
|
|
|
#pod |
56
|
|
|
|
|
|
|
#pod Maybe[Str] Object->strip_parameter_signature() |
57
|
|
|
|
|
|
|
#pod |
58
|
|
|
|
|
|
|
#pod This method is intended to parse the main namespace of a namespaced keyword. |
59
|
|
|
|
|
|
|
#pod It will use L<Devel::Declare::Context::Simple>s C<strip_word> method and store |
60
|
|
|
|
|
|
|
#pod the result in the L</namespace> attribute if true. |
61
|
|
|
|
|
|
|
#pod |
62
|
|
|
|
|
|
|
#pod =cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub strip_parameter_signature { |
65
|
14
|
|
|
14
|
1
|
22
|
my ($self) = @_; |
66
|
|
|
|
|
|
|
|
67
|
14
|
|
|
|
|
103
|
my $signature = $self->strip_proto; |
68
|
|
|
|
|
|
|
|
69
|
14
|
100
|
66
|
|
|
455
|
$self->parameter_signature($signature) |
70
|
|
|
|
|
|
|
if defined $signature && length $signature; |
71
|
|
|
|
|
|
|
|
72
|
14
|
|
|
|
|
36
|
return $signature; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
76
|
|
|
|
|
|
|
#pod |
77
|
|
|
|
|
|
|
#pod =for :list |
78
|
|
|
|
|
|
|
#pod * L<MooseX::Declare> |
79
|
|
|
|
|
|
|
#pod * L<MooseX::Declare::Context> |
80
|
|
|
|
|
|
|
#pod |
81
|
|
|
|
|
|
|
#pod =cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=pod |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=encoding UTF-8 |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 NAME |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
MooseX::Declare::Context::Parameterized - context for parsing optionally parameterized statements |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 VERSION |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
version 0.43 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 DESCRIPTION |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This context trait will add optional parameterization functionality to the |
102
|
|
|
|
|
|
|
context. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 parameter_signature |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This will be set when the C<strip_parameter_signature> method is called and it |
109
|
|
|
|
|
|
|
was able to extract a list of parameterisations. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 METHODS |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 has_parameter_signature |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Predicate method for the C<parameter_signature> attribute. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 add_parameter |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Allows storing parameters extracted from C<parameter_signature> to be used |
120
|
|
|
|
|
|
|
later on. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 get_parameters |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Returns all previously added parameters. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 strip_parameter_signature |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Maybe[Str] Object->strip_parameter_signature() |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This method is intended to parse the main namespace of a namespaced keyword. |
131
|
|
|
|
|
|
|
It will use L<Devel::Declare::Context::Simple>s C<strip_word> method and store |
132
|
|
|
|
|
|
|
the result in the L</namespace> attribute if true. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SEE ALSO |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=over 4 |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
L<MooseX::Declare> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
L<MooseX::Declare::Context> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=back |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 AUTHOR |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This software is copyright (c) 2008 by Florian Ragwitz. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
157
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |