1 use CatalystX::Declarative;
4 around match (@args) { $ENV{TESTAPP_ACTIONROLE} ? $self->$orig(@args) : undef }
7 role TestApp::Try::Aliasing::MyActionNo {
8 around match (@args) { $ENV{TESTAPP_ACTIONROLE} ? undef : $self->$orig(@args) }
11 class TestApp::Action::Page extends Catalyst::Action {
13 around execute ($controller, $ctx, @args) {
14 my $page = $ctx->request->params->{page} || 1;
15 return $self->$orig($controller, $ctx, @args, page => $page);
19 controller TestApp::Controller::Foo {
21 use constant MyActionNo => 'TestApp::Try::Aliasing::MyActionNo';
35 # normal methods are very useful too
38 method welcome_message { sprintf 'Welcome to %s!', $self->title }
40 method greet (Str $name) { "Hello, $name!" }
47 action base under '/base' as 'foo';
49 action root under base as '' is final {
50 $ctx->response->body( $self->welcome_message );
58 action with_args under base;
60 action hello (Str $name) under with_args is final {
61 $ctx->response->body($self->greet(ucfirst $name));
64 action at_end (Int $x, Int $y) under with_args is final {
65 $ctx->response->body( $x * $y );
68 action in_the_middle (Int $x, Int $y) under with_args {
69 $ctx->stash(result => $x * $y);
71 action end_of_the_middle under in_the_middle is final {
72 $ctx->response->body($ctx->stash->{result} * 2);
75 action all_the_way (Int $x) under with_args as '' {
78 action through_the_sky (Int $y) under all_the_way as '' {
81 action and_beyond (@rest) under through_the_sky as fhtagn is final {
82 $ctx->response->body(join ', ',
91 # under is also a valid keyword
94 under base action under_base as under;
96 under under_base as '' action even_more_under (Int $i) is final {
97 $ctx->response->body("under $i");
102 # too many words? go comma go!
105 action comma_base, as '', under base;
107 under comma_base, is final, action comma ($str), as ',comma' {
108 $ctx->response->body($str);
116 action lower under base;
128 action stream is final {
129 $ctx->response->body($ctx->action->reverse);
145 { $ctx->res->body('YES') };
152 { $ctx->res->body('NO') };
159 action book (Str $title) under base {
160 $ctx->stash(title => $title);
163 action view (Str $format, Int :$page) under book isa Page is final {
164 $ctx->response->body(
165 sprintf 'Page %d of "%s" as %s',
167 $ctx->stash->{title},