line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Declare::Syntax::InnerSyntaxHandling; |
2
|
|
|
|
|
|
|
# ABSTRACT: Keywords inside blocks |
3
|
|
|
|
|
|
|
$MooseX::Declare::Syntax::InnerSyntaxHandling::VERSION = '0.40'; |
4
|
24
|
|
|
24
|
|
15129
|
use Moose::Role; |
|
24
|
|
|
|
|
44
|
|
|
24
|
|
|
|
|
170
|
|
5
|
|
|
|
|
|
|
|
6
|
24
|
|
|
24
|
|
98492
|
use MooseX::Declare::Util qw( outer_stack_push ); |
|
24
|
|
|
|
|
45
|
|
|
24
|
|
|
|
|
204
|
|
7
|
|
|
|
|
|
|
|
8
|
24
|
|
|
24
|
|
4182
|
use namespace::clean -except => 'meta'; |
|
24
|
|
|
|
|
59
|
|
|
24
|
|
|
|
|
244
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
11
|
|
|
|
|
|
|
#pod |
12
|
|
|
|
|
|
|
#pod This role allows you to setup keyword handlers that are only available |
13
|
|
|
|
|
|
|
#pod inside blocks or other scoping environments. |
14
|
|
|
|
|
|
|
#pod |
15
|
|
|
|
|
|
|
#pod =head1 REQUIRED METHODS |
16
|
|
|
|
|
|
|
#pod |
17
|
|
|
|
|
|
|
#pod =head2 get_identifier |
18
|
|
|
|
|
|
|
#pod |
19
|
|
|
|
|
|
|
#pod Str get_identifier () |
20
|
|
|
|
|
|
|
#pod |
21
|
|
|
|
|
|
|
#pod Required to return the name of the identifier of the current handler. |
22
|
|
|
|
|
|
|
#pod |
23
|
|
|
|
|
|
|
#pod =cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
requires qw( |
26
|
|
|
|
|
|
|
get_identifier |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#pod =method default_inner |
30
|
|
|
|
|
|
|
#pod |
31
|
|
|
|
|
|
|
#pod ArrayRef[Object] Object->default_inner () |
32
|
|
|
|
|
|
|
#pod |
33
|
|
|
|
|
|
|
#pod Returns an empty C<ArrayRef> by default. If you want to setup additional |
34
|
|
|
|
|
|
|
#pod keywords you will have to C<around> this method. |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod =cut |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
1
|
0
|
sub default_inner { [] } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#pod =head1 MODIFIED METHODS |
41
|
|
|
|
|
|
|
#pod |
42
|
|
|
|
|
|
|
#pod =head2 setup_for |
43
|
|
|
|
|
|
|
#pod |
44
|
|
|
|
|
|
|
#pod Object->setup_for(ClassName $class, %args) |
45
|
|
|
|
|
|
|
#pod |
46
|
|
|
|
|
|
|
#pod After the keyword is setup inside itself, this will call L</setup_inner_for>. |
47
|
|
|
|
|
|
|
#pod |
48
|
|
|
|
|
|
|
#pod =cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
after setup_for => sub { |
51
|
|
|
|
|
|
|
my ($self, $setup_class, %args) = @_; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# make sure stack is valid |
54
|
|
|
|
|
|
|
my $stack = $args{stack} || []; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# setup inner keywords if we're inside ourself |
57
|
|
|
|
|
|
|
if (grep { $_ eq $self->get_identifier } @$stack) { |
58
|
|
|
|
|
|
|
$self->setup_inner_for($setup_class, %args); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
}; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
#pod =method setup_inner_for |
63
|
|
|
|
|
|
|
#pod |
64
|
|
|
|
|
|
|
#pod Object->setup_inner_for(ClassName $class, %args) |
65
|
|
|
|
|
|
|
#pod |
66
|
|
|
|
|
|
|
#pod Sets up all handlers in the inner class. |
67
|
|
|
|
|
|
|
#pod |
68
|
|
|
|
|
|
|
#pod =cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub setup_inner_for { |
71
|
61
|
|
|
61
|
1
|
580
|
my ($self, $setup_class, %args) = @_; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# setup each keyword in target class |
74
|
61
|
|
|
|
|
86
|
for my $inner (@{ $self->default_inner($args{stack}) }) { |
|
61
|
|
|
|
|
273
|
|
75
|
427
|
|
|
|
|
14760
|
$inner->setup_for($setup_class, %args); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# push package onto stack for namespace management |
79
|
61
|
50
|
|
|
|
290
|
if (exists $args{file}) { |
80
|
61
|
|
|
|
|
340
|
outer_stack_push $args{file}, $args{outer_package}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
85
|
|
|
|
|
|
|
#pod |
86
|
|
|
|
|
|
|
#pod =for :list |
87
|
|
|
|
|
|
|
#pod * L<MooseX::Declare> |
88
|
|
|
|
|
|
|
#pod * L<MooseX::Declare::Syntax::NamespaceHandling> |
89
|
|
|
|
|
|
|
#pod * L<MooseX::Declare::Syntax::MooseSetup> |
90
|
|
|
|
|
|
|
#pod |
91
|
|
|
|
|
|
|
#pod =cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
__END__ |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=pod |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=encoding UTF-8 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 NAME |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
MooseX::Declare::Syntax::InnerSyntaxHandling - Keywords inside blocks |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 VERSION |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
version 0.40 |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 DESCRIPTION |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This role allows you to setup keyword handlers that are only available |
112
|
|
|
|
|
|
|
inside blocks or other scoping environments. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 METHODS |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 default_inner |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
ArrayRef[Object] Object->default_inner () |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Returns an empty C<ArrayRef> by default. If you want to setup additional |
121
|
|
|
|
|
|
|
keywords you will have to C<around> this method. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 setup_inner_for |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Object->setup_inner_for(ClassName $class, %args) |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Sets up all handlers in the inner class. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 REQUIRED METHODS |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 get_identifier |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Str get_identifier () |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Required to return the name of the identifier of the current handler. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 MODIFIED METHODS |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 setup_for |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Object->setup_for(ClassName $class, %args) |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
After the keyword is setup inside itself, this will call L</setup_inner_for>. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 SEE ALSO |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=over 4 |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L<MooseX::Declare> |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
L<MooseX::Declare::Syntax::NamespaceHandling> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
L<MooseX::Declare::Syntax::MooseSetup> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=back |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 AUTHOR |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This software is copyright (c) 2008 by Florian Ragwitz. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
172
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=cut |