use strict;
use base qw/Class::Accessor::Fast/;
+
+=head1 NAME
+
+Catalyst::Action - Catalyst Action
+
+=head1 SYNOPSIS
+
+ <form action="[%c.uri_for(c.action.reverse)%]">
+
+=head1 DESCRIPTION
+
+This class represents a Catalyst Action. You can access the object for the
+currently dispatched action via $c->action. See the L<Catalyst::Dispatcher>
+for more information on how actions are dispatched. Actions are defined in
+L<Catalyst::Controller> subclasses.
+
+=cut
+
__PACKAGE__->mk_accessors(qw/class namespace reverse attributes name code/);
use overload (
);
-=head1 NAME
-
-Catalyst::Action - Catalyst Action
+sub dispatch { # Execute ourselves against a context
+ my ( $self, $c ) = @_;
+ local $c->namespace = $self->namespace;
+ return $c->execute( $self->class, $self );
+}
-=head1 SYNOPSIS
+sub execute {
+ my $self = shift;
+ $self->{code}->(@_);
+}
-See L<Catalyst>.
+sub match {
+ my ( $self, $c ) = @_;
+ return 1 unless exists $self->attributes->{Args};
+ my $args = $self->attributes->{Args}[0];
+ return 1 unless defined($args) && length($args);
+ return scalar( @{ $c->req->args } ) == $args;
+}
-=head1 DESCRIPTION
+1;
-This class represents a Catalyst Action. You can access the object for the
-currently dispatched action via $c->action
+__END__
=head1 METHODS
=head2 attributes
The sub attributes that are set for this action, like Local, Path, Private
-and so on.
+and so on. This determines how the action is dispatched to.
=head2 class
-Returns the class name of this action
+Returns the class name where this action is defined.
=head2 code
-Returns a code reference to this action
+Returns a code reference to this action.
=head2 dispatch( $c )
Dispatch this action against a context
-=cut
-
-sub dispatch { # Execute ourselves against a context
- my ( $self, $c ) = @_;
- local $c->namespace = $self->namespace;
- return $c->execute( $self->class, $self );
-}
-
=head2 execute( $controller, $c, @args )
Execute this action's coderef against a given controller with a given
context and arguments
-=cut
-
-sub execute {
- my $self = shift;
- $self->{code}->(@_);
-}
-
=head2 match( $c )
Check Args attribute, and makes sure number of args matches the setting.
-
-=cut
-
-sub match {
- my ( $self, $c ) = @_;
- return 1 unless exists $self->attributes->{Args};
- my $args = $self->attributes->{Args}[0];
- return 1 unless defined($args) && length($args);
- return scalar( @{ $c->req->args } ) == $args;
-}
+Always returns true if Args is omitted.
=head2 namespace
This program is free software, you can redistribute it and/or modify it under
the same terms as Perl itself.
-=cut
-
-1;
+=cut
\ No newline at end of file
use strict;
use base qw/Catalyst::Action/;
-__PACKAGE__->mk_accessors(qw/chain/);
-
-use overload (
-
- # Stringify to reverse for debug output etc.
- q{""} => sub { shift->{reverse} },
-
- # Codulate to execute to invoke the encapsulated action coderef
- '&{}' => sub { my $self = shift; sub { $self->execute(@_); }; },
-
- # Make general $stuff still work
- fallback => 1,
-
-);
=head1 NAME
=head1 SYNOPSIS
-See L<Catalyst>.
+See L<Catalyst::Manual::Intro> for more info about Chained actions.
=head1 DESCRIPTION
the action at the *end* of the chain except on dispatch it will execute all
the actions in the chain in order.
-=head1 METHODS
+=cut
-=head2 chain
+__PACKAGE__->mk_accessors(qw/chain/);
-Accessor for the action chain; will be an arrayref of the Catalyst::Action
-objects encapsulated by this chain.
+use overload (
-=head2 dispatch( $c )
+ # Stringify to reverse for debug output etc.
+ q{""} => sub { shift->{reverse} },
-Dispatch this action chain against a context; will dispatch the encapsulated
-actions in order.
+ # Codulate to execute to invoke the encapsulated action coderef
+ '&{}' => sub { my $self = shift; sub { $self->execute(@_); }; },
+
+ # Make general $stuff still work
+ fallback => 1,
+
+);
-=cut
sub dispatch {
my ( $self, $c ) = @_;
$last->dispatch( $c );
}
+sub from_chain {
+ my ( $self, $actions ) = @_;
+ my $final = $actions->[-1];
+ return $self->new({ %$final, chain => $actions });
+}
+
+1;
+
+__END__
+
+=head1 METHODS
+
+=head2 chain
+
+Accessor for the action chain; will be an arrayref of the Catalyst::Action
+objects encapsulated by this chain.
+
+=head2 dispatch( $c )
+
+Dispatch this action chain against a context; will dispatch the encapsulated
+actions in order.
+
=head2 from_chain( \@actions )
Takes a list of Catalyst::Action objects and constructs and returns a
=cut
-sub from_chain {
- my ( $self, $actions ) = @_;
- my $final = $actions->[-1];
- return $self->new({ %$final, chain => $actions });
-}
-
=head1 AUTHOR
Matt S. Trout
the same terms as Perl itself.
=cut
-
-1;
use strict;
use base qw/Class::Accessor::Fast/;
+=head1 NAME
+
+Catalyst::ActionContainer - Catalyst Action Container
+
+=head1 SYNOPSIS
+
+See L<Catalyst>.
+
+=head1 DESCRIPTION
+
+This is a container for actions. The dispatcher sets up a tree of these
+to represent the various dispatch points in your application.
+
+=cut
+
__PACKAGE__->mk_accessors(qw/part actions/);
use overload (
$class->SUPER::new($fields);
}
-=head1 NAME
-Catalyst::ActionContainer - Catalyst Action Container
-=head1 SYNOPSIS
+sub get_action {
+ my ( $self, $name ) = @_;
+ return $self->actions->{$name} if defined $self->actions->{$name};
+ return;
+}
-See L<Catalyst>.
+sub add_action {
+ my ( $self, $action, $name ) = @_;
+ $name ||= $action->name;
+ $self->actions->{$name} = $action;
+}
-=head1 DESCRIPTION
+1;
-This is a container for actions. The dispatcher sets up a tree of these
-to represent the various dispatch points in your application.
+__END__
=head1 METHODS
Returns an action from this container based on the action name, or undef
-=cut
-
-sub get_action {
- my ( $self, $name ) = @_;
- return $self->actions->{$name} if defined $self->actions->{$name};
- return;
-}
-
=head2 add_action($action, [ $name ])
Adds an action, optionally providing a name to override $action->name
-=cut
-
-sub add_action {
- my ( $self, $action, $name ) = @_;
- $name ||= $action->name;
- $self->actions->{$name} = $action;
-}
-
=head2 actions
Accessor to the actions hashref, containing all actions in this container.
=head1 AUTHOR
-Matt S. Trout
+Matt S. Trout
=head1 COPYRIGHT