1 package Catalyst::Action;
4 use base qw/Class::Accessor::Fast/;
6 __PACKAGE__->mk_accessors(qw/class namespace reverse attributes name code/);
10 # Stringify to reverse for debug output etc.
11 q{""} => sub { shift->{reverse} },
13 # Codulate to execute to invoke the encapsulated action coderef
14 '&{}' => sub { my $self = shift; sub { $self->execute(@_); }; },
16 # Make general $stuff still work
23 Catalyst::Action - Catalyst Action
31 This class represents a Catalyst Action. You can access the object for the
32 currently dispatched action via $c->action
38 The sub attributes that are set for this action, like Local, Path, Private
43 Returns the class name of this action
47 Returns a code reference to this action
51 Dispatch this action against a context
55 sub dispatch { # Execute ourselves against a context
56 my ( $self, $c ) = @_;
57 local $c->namespace = $self->namespace;
58 return $c->execute( $self->class, $self );
61 =head2 execute( $controller, $c, @args )
63 Execute this action's coderef against a given controller with a given
75 Check Args attribute, and makes sure number of args matches the setting.
80 my ( $self, $c ) = @_;
81 return 1 unless exists $self->attributes->{Args};
82 my $args = $self->attributes->{Args}[0];
83 return 1 unless defined($args) && length($args);
84 return scalar( @{ $c->req->args } ) == $args;
89 Returns the private namespace this action lives in.
93 Returns the private path for this action.
97 returns the sub name of this action.
105 This program is free software, you can redistribute it and/or modify it under
106 the same terms as Perl itself.