Catalyst Tip: Were we forwarded here?

LTjake on 2006-08-16T19:35:24

A handy little tip -- if you need to figure out if you're inside a forwarded action or not do this simple comparison:

if( $c->action eq $c->stack->[ -1 ] ) {
    # We've not been forwarded yet
}

$c->action is the Catalyst::Action object for the current action and $c->stack->[ -1 ] is the Catalyst::Action for the current sub (which will always be the last item in the call stack).