fixed sort order bug
[catagits/Catalyst-Runtime.git] / lib / Catalyst / ActionChain.pm
index ceb7c81..6d16104 100644 (file)
@@ -49,14 +49,17 @@ actions in order.
 sub dispatch {
     my ( $self, $c ) = @_;
     my @captures = @{$c->req->captures||[]};
-    foreach my $action ( @{ $self->chain } ) {
+    my @chain = @{ $self->chain };
+    my $last = pop(@chain);
+    foreach my $action ( @chain ) {
         my @args;
-        if (my $cap = $action->attributes->{Captures}) {
+        if (my $cap = $action->attributes->{CaptureArgs}) {
           @args = splice(@captures, 0, $cap->[0]);
         }
         local $c->request->{arguments} = \@args;
         $action->dispatch( $c );
     }
+    $last->dispatch( $c );
 }
 
 =head2 from_chain( \@actions )