line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::Declare::Syntax::Keyword::With; |
2
|
|
|
|
|
|
|
# ABSTRACT: Apply roles within a class- or role-body |
3
|
|
|
|
|
|
|
$MooseX::Declare::Syntax::Keyword::With::VERSION = '0.39'; |
4
|
24
|
|
|
24
|
|
48320
|
use Moose; |
|
24
|
|
|
|
|
65
|
|
|
24
|
|
|
|
|
365
|
|
5
|
24
|
|
|
24
|
|
198985
|
use Moose::Util; |
|
24
|
|
|
|
|
68
|
|
|
24
|
|
|
|
|
361
|
|
6
|
24
|
|
|
24
|
|
36542
|
use MooseX::Declare::Util qw( outer_stack_peek ); |
|
24
|
|
|
|
|
84
|
|
|
24
|
|
|
|
|
159
|
|
7
|
24
|
|
|
24
|
|
5224
|
use aliased 'MooseX::Declare::Context::Namespaced'; |
|
24
|
|
|
|
|
58
|
|
|
24
|
|
|
|
|
270
|
|
8
|
24
|
|
|
24
|
|
2704
|
use namespace::autoclean 0.09; |
|
24
|
|
|
|
|
831
|
|
|
24
|
|
|
|
|
223
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
11
|
|
|
|
|
|
|
#pod |
12
|
|
|
|
|
|
|
#pod use MooseX::Declare; |
13
|
|
|
|
|
|
|
#pod |
14
|
|
|
|
|
|
|
#pod class ::Baz { |
15
|
|
|
|
|
|
|
#pod with 'Qux'; |
16
|
|
|
|
|
|
|
#pod ... |
17
|
|
|
|
|
|
|
#pod } |
18
|
|
|
|
|
|
|
#pod |
19
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
20
|
|
|
|
|
|
|
#pod |
21
|
|
|
|
|
|
|
#pod The C<with> keyword allows you to apply roles to the local class or role. It |
22
|
|
|
|
|
|
|
#pod differs from the C<with>-option of the C<class> and C<role> keywords in that it |
23
|
|
|
|
|
|
|
#pod applies the roles immediately instead of defering application until the end of |
24
|
|
|
|
|
|
|
#pod the class- or role-definition. |
25
|
|
|
|
|
|
|
#pod |
26
|
|
|
|
|
|
|
#pod It also differs slightly from the C<with> provided by L<Moose|Moose> in that it |
27
|
|
|
|
|
|
|
#pod expands relative role names (C<::Foo>) according to the currenc C<namespace>. |
28
|
|
|
|
|
|
|
#pod |
29
|
|
|
|
|
|
|
#pod =head1 CONSUMES |
30
|
|
|
|
|
|
|
#pod |
31
|
|
|
|
|
|
|
#pod =for :list |
32
|
|
|
|
|
|
|
#pod * L<MooseX::Declare::Syntax::KeywordHandling> |
33
|
|
|
|
|
|
|
#pod |
34
|
|
|
|
|
|
|
#pod =cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
with qw( |
37
|
|
|
|
|
|
|
MooseX::Declare::Syntax::KeywordHandling |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
around context_traits => sub { shift->(@_), Namespaced }; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#pod =method parse |
43
|
|
|
|
|
|
|
#pod |
44
|
|
|
|
|
|
|
#pod Object->parse(Object $context) |
45
|
|
|
|
|
|
|
#pod |
46
|
|
|
|
|
|
|
#pod Will skip the declarator and make with C<with> invocation apply the set of |
47
|
|
|
|
|
|
|
#pod specified roles after possible C<namespace>-expanding has been done. |
48
|
|
|
|
|
|
|
#pod |
49
|
|
|
|
|
|
|
#pod =cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub parse { |
52
|
10
|
|
|
10
|
1
|
29
|
my ($self, $ctx) = @_; |
53
|
|
|
|
|
|
|
|
54
|
10
|
|
|
|
|
146
|
$ctx->skip_declarator; |
55
|
|
|
|
|
|
|
|
56
|
10
|
|
|
|
|
900
|
my $pkg = outer_stack_peek $ctx->caller_file; |
57
|
|
|
|
|
|
|
$ctx->shadow(sub { |
58
|
13
|
|
|
|
|
92
|
Moose::Util::apply_all_roles($pkg, map { |
59
|
10
|
|
|
10
|
|
157
|
$ctx->qualify_namespace($_) |
60
|
|
|
|
|
|
|
} @_); |
61
|
10
|
|
|
|
|
119
|
}); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
65
|
|
|
|
|
|
|
#pod |
66
|
|
|
|
|
|
|
#pod =for :list |
67
|
|
|
|
|
|
|
#pod * L<MooseX::Declare> |
68
|
|
|
|
|
|
|
#pod * L<MooseX::Declare::Syntax::Keyword::Namespace> |
69
|
|
|
|
|
|
|
#pod |
70
|
|
|
|
|
|
|
#pod =cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=pod |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=encoding UTF-8 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 NAME |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
MooseX::Declare::Syntax::Keyword::With - Apply roles within a class- or role-body |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 VERSION |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
version 0.39 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SYNOPSIS |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
use MooseX::Declare; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
class ::Baz { |
93
|
|
|
|
|
|
|
with 'Qux'; |
94
|
|
|
|
|
|
|
... |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 DESCRIPTION |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
The C<with> keyword allows you to apply roles to the local class or role. It |
100
|
|
|
|
|
|
|
differs from the C<with>-option of the C<class> and C<role> keywords in that it |
101
|
|
|
|
|
|
|
applies the roles immediately instead of defering application until the end of |
102
|
|
|
|
|
|
|
the class- or role-definition. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
It also differs slightly from the C<with> provided by L<Moose|Moose> in that it |
105
|
|
|
|
|
|
|
expands relative role names (C<::Foo>) according to the currenc C<namespace>. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 METHODS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 parse |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Object->parse(Object $context) |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Will skip the declarator and make with C<with> invocation apply the set of |
114
|
|
|
|
|
|
|
specified roles after possible C<namespace>-expanding has been done. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 CONSUMES |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=over 4 |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item * |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
L<MooseX::Declare::Syntax::KeywordHandling> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=back |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SEE ALSO |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=over 4 |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
L<MooseX::Declare> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item * |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
L<MooseX::Declare::Syntax::Keyword::Namespace> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=back |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 AUTHOR |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This software is copyright (c) 2008 by Florian Ragwitz. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
149
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |