# we need to fish for aliases here since we are still unclean
my @roles = ();
for my $role_with_arg(@roles_with_args) {
- my $role = $role_with_arg->[0];
+ my ($role, $params) = @{$role_with_arg};
+ if($params) {
+ my ($first, @rest) = eval $params;
+ my %params = ref $first eq 'HASH' ? %$first : ($first, @rest);
+ for my $key (keys %params) {
+ $attrs->{$key} = [$params{$key}];
+ }
+ }
+
if (defined(my $alias = $self->_check_for_available_import($ctx, $role))) {
$role = $alias;
}
# fix bug with capture args below under { }
is get('/foo/lower/down/the/param/3/road/5'), 8, 'capture args and block under work together';
+# Make sure action roles with parameters pass params to attributes
+is get('/actionparams/first'), 'action_args_first: 100,101', 'actionrole with params';
+is get('/actionparams/second'), 'action_args_second: 200,201', 'actionrole with params (part two)';
done_testing;
--- /dev/null
+use CatalystX::Declare;
+namespace TestApp;
+
+role hasActionParams {
+ has [qw/p1 p2/] => (is=>'ro', lazy_build=>1);
+
+ method _build_p1 {
+ $self->attributes->{p1}->[0];
+ }
+ method _build_p2 {
+ $self->attributes->{p2}->[0];
+ }
+}
+
+controller ::Controller::ActionParams {
+
+ action base
+ under '/base'
+ as 'actionparams';
+
+ action first under base
+ with hasActionParams(p1=>100,p2=>101)
+ is final {
+ my $p1 = $ctx->controller->action_for('first')->p1;
+ my $p2 = $ctx->controller->action_for('first')->p2;
+ $ctx->response->body("action_args_first: $p1,$p2");
+ }
+
+ action second under base
+ with hasActionParams({p1=>200,p2=>201})
+ is final {
+ my $p1 = $ctx->controller->action_for('second')->p1;
+ my $p2 = $ctx->controller->action_for('second')->p2;
+ $ctx->response->body("action_args_second: $p1,$p2");
+ }
+
+}
+