my ($role, $params) = @{$role_with_arg};
if($params) {
my ($first, @rest) = eval $params;
- my %params = ref $first eq 'HASH' ? %$first : ($first, @rest);
+ my %params = ref $first eq 'HASH' ? %$first : ($first, @rest); # both (%opts) and {%opts}
for my $key (keys %params) {
- $attrs->{$key} = [$params{$key}];
+ push @{$attrs->{$key}}, $params{$key};
}
}
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)';
is get('/actionparams/third'), 'action_args_third: 300,301', 'actionrole with params (part three)';
+is get('/actionparams/forth'), 'action_args_forth: 400,1,401,2', 'actionrole with params (part four)';
done_testing;
has [qw/p1 p2/] => (is=>'ro', lazy_build=>1);
method _build_p1 {
- $self->attributes->{p1}->[0];
+ join ',', @{$self->attributes->{p1}};
}
method _build_p2 {
- $self->attributes->{p2}->[0];
+ join ',', @{$self->attributes->{p2}};
}
}
my $p2 = $ctx->controller->action_for('third')->p2;
$ctx->response->body("action_args_third: $p1,$p2");
}
+
+ action forth under base
+ with (hasActionParams(
+ p1=>400,
+ p2=>401,
+ ), hasActionParams(p1=>1,p2=>2)) is final {
+ my $p1 = $ctx->controller->action_for('forth')->p1;
+ my $p2 = $ctx->controller->action_for('forth')->p2;
+ $ctx->response->body("action_args_forth: $p1,$p2");
+ }
}