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