parse actionrole params and pass them to attributes
[catagits/CatalystX-Declare.git] / t / lib / TestApp / Controller / ActionParams.pm
CommitLineData
d14acb87 1use CatalystX::Declare;
2namespace TestApp;
3
4role hasActionParams {
5 has [qw/p1 p2/] => (is=>'ro', lazy_build=>1);
6
7 method _build_p1 {
8 $self->attributes->{p1}->[0];
9 }
10 method _build_p2 {
11 $self->attributes->{p2}->[0];
12 }
13}
14
15controller ::Controller::ActionParams {
16
17 action base
18 under '/base'
19 as 'actionparams';
20
21 action first under base
22 with hasActionParams(p1=>100,p2=>101)
23 is final {
24 my $p1 = $ctx->controller->action_for('first')->p1;
25 my $p2 = $ctx->controller->action_for('first')->p2;
26 $ctx->response->body("action_args_first: $p1,$p2");
27 }
28
29 action second under base
30 with hasActionParams({p1=>200,p2=>201})
31 is final {
32 my $p1 = $ctx->controller->action_for('second')->p1;
33 my $p2 = $ctx->controller->action_for('second')->p2;
34 $ctx->response->body("action_args_second: $p1,$p2");
35 }
36
37}
38