Catalyst::Plugin::Digress - A cleaner, simpler, action-only $c->forward
$c->digress( 'some/other/action' );
$c->digress( 'action_in_same_controller' );
$c->digress( $self->action_for( 'action_in_same_controller' ) );
my %form = $c->digress( 'validate_params', {
name => { required => 1 },
email => { type => 'Str' },
} );
$c->digress( $c->view ); # FAIL: cannot digress to components
This plugin gives you the useful part of the Catalyst forward
method without the weirdness (or the madness).
This is akin to forward
, with the following differences:
It does not catch exceptions (the most important benefit).
It passes parameters like in a normal Perl method call.
It does not mess with
$c->request->arguments
.It preserves list vs scalar context for the call.
It does not walk the Perl call stack every time (or ever, even once) to figure out what its own name was (or for any other purpose).
It cannot forward to components, only actions (because don’t ask how forwarding to components works).
In other words, is almost identical to a straight method call:
package MyApp::Controller::Some;
sub other_action : Private { ... }
package MyApp::Controller::Root;
sub index : Path {
my ( $c, @some_args ) = ( shift, @_ );
# ...
my @some_return = $c->digress( '/some/other_action', @any_old_args );
# this is nearly identical to the following line:
my @some_return = $c->controller( 'Some' )->other_action( $c, @any_old_args );
# ...
}
Except, of course, that it takes an action path instead of a plain method name, and it maintains the Catalyst action stack for you just like forward
would, which keeps various Catalyst mechanisms working, such as calling forward
and friends from other_action
with a local action name.