my $c = shift;
my $command = shift;
- $command = ref $command if ref $command;
-
unless ($command) {
$c->log->debug('Nothing to forward to') if $c->debug;
return 0;
my $result;
- my $command_copy = $command;
+ unless ( ref $command ) {
+ my $command_copy = $command;
- unless ( $command_copy =~ s/^\/// ) {
- my $namespace = $c->namespace;
- $command_copy = "${namespace}/${command}";
- }
+ unless ( $command_copy =~ s/^\/// ) {
+ my $namespace = $c->namespace;
+ $command_copy = "${namespace}/${command}";
+ }
- unless ( $command_copy =~ /\// ) {
- $result = $c->get_action( $command_copy, '/' );
- }
- else {
- my @extra_args;
- DESCEND: while ( $command_copy =~ s/^(.*)\/(\w+)$/$1/ ) {
- my $tail = $2;
- $result = $c->get_action( $tail, $1 );
- if ($result) {
- $command = $tail;
- push( @{$arguments}, @extra_args );
- last DESCEND;
+ unless ( $command_copy =~ /\// ) {
+ $result = $c->get_action( $command_copy, '/' );
+ }
+ else {
+ my @extra_args;
+ DESCEND: while ( $command_copy =~ s/^(.*)\/(\w+)$/$1/ ) {
+ my $tail = $2;
+ $result = $c->get_action( $tail, $1 );
+ if ($result) {
+ $command = $tail;
+ push( @{$arguments}, @extra_args );
+ last DESCEND;
+ }
+ unshift( @extra_args, $tail );
}
- unshift( @extra_args, $tail );
}
}
unless ($result) {
- my $comp;
+ my $class = ref($command) || ref( $c->component($command) );
+ my $method = shift || 'process';
- unless ( $comp = $c->component($command) ) {
+ unless ($class) {
my $error =
qq/Couldn't forward to command "$command". Invalid action or component./;
$c->error($error);
return 0;
}
- my $class = ref $comp;
- my $method = shift || 'process';
-
if ( my $code = $class->can($method) ) {
my $action = $self->method_action_class->new(
{
# should catch any failures - or short-circuit this if this *is* a
# bug in the visitor and gets fixed.
- my $extra = $path[ ( scalar @match ) - 1 ];
- last unless $extra;
- $visitor->setSearchPath($extra);
- $match[-1]->accept($visitor);
- push( @match, $visitor->getResult ) if defined $visitor->getResult;
+ if ( my $extra = $path[ ( scalar @match ) - 1 ] ) {
+ $visitor->setSearchPath($extra);
+ $match[-1]->accept($visitor);
+ push( @match, $visitor->getResult ) if defined $visitor->getResult;
+ }
}
return map { $_->getNodeValue } @match;
Catalyst::ActionContainer->new( { part => '/', actions => {} } );
$self->tree( Tree::Simple->new( $container, Tree::Simple->ROOT ) );
- $c->register_actions($c);
-
foreach my $comp ( values %{ $c->components } ) {
$comp->register_actions($c) if $comp->can('register_actions');
}