| MooseX-Declare documentation | Contained in the MooseX-Declare distribution. |
MooseX::Declare::Syntax::RoleApplication - Handle user specified roles
This role extends MooseX::Declare::Syntax::OptionHandling and provides
a with|/add_with_option_customizations option.
Object->add_with_option_customizations (
Object $context,
Str $package,
ArrayRef $roles,
HashRef $options
)
This will add a call to with in the scope code.
This software is copyright (c) 2010 by Florian Ragwitz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
| MooseX-Declare documentation | Contained in the MooseX-Declare distribution. |
package MooseX::Declare::Syntax::RoleApplication; BEGIN { $MooseX::Declare::Syntax::RoleApplication::AUTHORITY = 'cpan:FLORA'; } BEGIN { $MooseX::Declare::Syntax::RoleApplication::VERSION = '0.34'; } # ABSTRACT: Handle user specified roles use Moose::Role; use aliased 'MooseX::Declare::Context::Namespaced'; use namespace::clean -except => 'meta'; with qw( MooseX::Declare::Syntax::OptionHandling ); around context_traits => sub { shift->(@_), Namespaced }; sub add_with_option_customizations { my ($self, $ctx, $package, $roles) = @_; # consume roles $ctx->add_early_cleanup_code_parts( sprintf 'Moose::Util::apply_all_roles(%s->meta, %s)', $package, join ', ', map { "q[$_]" } map { $ctx->qualify_namespace($_) } @{ $roles }, ); return 1; } 1; __END__