1 package Catalyst::ActionChain;
4 extends qw(Catalyst::Action);
6 has chain => (is => 'rw');
12 Catalyst::ActionChain - Chain of Catalyst Actions
16 See L<Catalyst::Manual::Intro> for more info about Chained actions.
20 This class represents a chain of Catalyst Actions. It behaves exactly like
21 the action at the *end* of the chain except on dispatch it will execute all
22 the actions in the chain in order.
27 my ( $self, $c ) = @_;
28 my @captures = @{$c->req->captures||[]};
29 my @chain = @{ $self->chain };
30 my $last = pop(@chain);
31 foreach my $action ( @chain ) {
33 if (my $cap = $action->attributes->{CaptureArgs}) {
34 @args = splice(@captures, 0, $cap->[0]);
36 local $c->request->{arguments} = \@args;
37 $action->dispatch( $c );
39 $last->dispatch( $c );
43 my ( $self, $actions ) = @_;
44 my $final = $actions->[-1];
45 return $self->new({ %$final, chain => $actions });
48 __PACKAGE__->meta->make_immutable;
57 Accessor for the action chain; will be an arrayref of the Catalyst::Action
58 objects encapsulated by this chain.
62 Dispatch this action chain against a context; will dispatch the encapsulated
65 =head2 from_chain( \@actions )
67 Takes a list of Catalyst::Action objects and constructs and returns a
68 Catalyst::ActionChain object representing a chain of these actions
76 Catalyst Contributors, see Catalyst.pm
80 This library is free software. You can redistribute it and/or modify it under
81 the same terms as Perl itself.