Created
August 18, 2010 14:50
-
-
Save jjn1056/534978 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use CatalystX::Declare; | |
namespace TestApp; | |
role hasActionParams { | |
has [qw/p1 p2/] => (is=>'ro', lazy_build=>1); | |
method _build_p1 { | |
join ',', @{$self->attributes->{p1}}; | |
} | |
method _build_p2 { | |
join ',', @{$self->attributes->{p2}}; | |
} | |
} | |
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"); | |
} | |
action third under base | |
with hasActionParams( | |
p1=>300, | |
p2=>301, | |
) is final { | |
my $p1 = $ctx->controller->action_for('third')->p1; | |
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"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment