use aliased 'MooseX::MethodAttributes::Role::Meta::Role';
- use aliased 'CatalystX::Declare::Keyword::Action', 'ActionKeyword';
+ use aliased 'MooseX::Role::Parameterized::Meta::Role::Parameterizable';
+ use aliased 'CatalystX::Declare::Keyword::Action', 'ActionKeyword';
+ around import_symbols_from (Object $ctx) {
+
+ $ctx->has_parameter_signature
+ ? $self->$orig($ctx)
+ : sprintf('Moose::Role -traits => q(MethodAttributes),')
+ }
+
before add_namespace_customizations (Object $ctx, Str $package) {
+ my $source = $self->import_symbols_from($ctx);
+ my @symbols = $self->imported_moose_symbols;
+
$ctx->add_preamble_code_parts(
'use CLASS',
- 'use Moose::Role -traits => q(MethodAttributes)',
);
}
- around default_inner {
+ after add_namespace_customizations (Object $ctx, Str $package) {
- my @modifiers = qw( );
+ $ctx->add_preamble_code_parts(
+ sprintf(
+ 'use %s -traits => q(%s), qw( has )',
+ 'MooseX::Role::Parameterized',
+ 'MooseX::MethodAttributes::Role::Meta::Role',
+ ),
+ ) if $ctx->has_parameter_signature;
+ }
+
+ around default_inner (@args) {
return [
- ( grep { my $id = $_->identifier; not grep { $id eq $_ } @modifiers } @{ $self->$orig() || [] } ),
+ @{ $self->$orig(@args) },
ActionKeyword->new(identifier => 'action'),
ActionKeyword->new(identifier => 'under'),
ActionKeyword->new(identifier => 'final'),
around bar_action (Object $ctx) { ... }
}
+ controller_role MyApp::Web::ControllerRole::WithParam (Str :$msg!) {
+
+ final action message under base {
+ $ctx->stash(message => $msg);
+ }
+ }
+
=head1 DESCRIPTION
This handler provides the C<controller_role> keyword. It is an extension of the
L<CatalystX::Declare::Keyword::Action>, which also documents the effects of
method modifiers on actions.
+=head2 Parameters
+
+You can use a parameter signature containing named parameters for a role. To
+apply the controller role in the L</SYNOPSIS>, you'd use code like this:
+
+ controller MyApp::Web::Controller::Hello {
+ with 'MyApp::Web::ControllerRole::WithParam' => { msg => 'Hello!' };
+
+ action base under '/' as '';
+ }
+
=head1 SUPERCLASSES
=over