1 package MooseX::Declare::Syntax::Keyword::With;
5 use MooseX::Declare::Util qw( outer_stack_peek );
6 use aliased 'MooseX::Declare::Context::Namespaced';
7 use namespace::autoclean;
10 MooseX::Declare::Syntax::KeywordHandling
13 around context_traits => sub { shift->(@_), Namespaced };
16 my ($self, $ctx) = @_;
18 $ctx->skip_declarator;
20 my $pkg = outer_stack_peek $ctx->caller_file;
22 Moose::Util::apply_all_roles($pkg, map {
23 $ctx->qualify_namespace($_)
32 MooseX::Declare::Syntax::Keyword::With - Apply roles within a class- or role-body
45 The C<with> keyword allows you to apply roles to the local class or role. It
46 differs from the C<with>-option of the C<class> and C<role> keywords in that it
47 applies the roles immediately instead of defering application until the end of
48 the class- or role-definition.
50 It also differs slightly from the C<with> provided by L<Moose|Moose> in that it
51 expands relative role names (C<::Foo>) according to the currenc C<namespace>.
57 =item * L<MooseX::Declare::Syntax::KeywordHandling>
65 Object->parse(Object $context)
67 Will skip the declarator and make with C<with> invocation apply the set of
68 specified roles after possible C<namespace>-expanding has been done.
74 =item * L<MooseX::Declare>
76 =item * L<MooseX::Declare::Syntax::Keyword::Namespace>
80 =head1 AUTHOR, COPYRIGHT & LICENSE
82 See L<MooseX::Declare>