use Class::Inspector;
use NEXT;
-__PACKAGE__->mk_classdata($_) for qw/_dispatch_steps/;
+__PACKAGE__->mk_classdata($_) for qw/_dispatch_steps _action_class/;
__PACKAGE__->_dispatch_steps( [qw/_BEGIN _AUTO _ACTION/] );
+__PACKAGE__->_action_class('Catalyst::Action');
sub _DISPATCH : Private {
my ( $self, $c ) = @_;
sub _ACTION : Private {
my ( $self, $c ) = @_;
- $c->action->execute($c);
+ if ( ref $c->action
+ && $c->action->can('execute')
+ && $c->req->action )
+ {
+ $c->action->execute($c);
+ }
return !@{ $c->error };
}
return !@{ $c->error };
}
+=head1 NAME
+
+Catalyst::Base - Catalyst Base Class
+
+=head1 SYNOPSIS
+
+See L<Catalyst>
+
+=head1 DESCRIPTION
+
+Catalyst Base Class
+
+=head1 METHODS
+
+=head2 $self->action_namespace($c)
+
+=cut
+
sub action_namespace {
my ( $self, $c ) = @_;
- return Catalyst::Utils::class2prefix( ref $self,
+ return $self->config->{namespace} if exists $self->config->{namespace};
+ return Catalyst::Utils::class2prefix( ref($self) || $self,
$c->config->{case_sensitive} )
|| '';
}
+=head2 $self->register_actions($c)
+
+=cut
+
sub register_actions {
my ( $self, $c ) = @_;
my $class = ref $self || $self;
next;
}
my $reverse = $namespace ? "$namespace/$method" : $method;
- my $action = Catalyst::Action->new(
+ my $action = $self->_action_class->new(
{
name => $method,
code => $code,
# Parse out :Foo(bar) into Foo => bar etc (and arrayify)
- if ( my ( $key, $value ) = ( $attr =~ /^(.*?)(?:\(\s*(.+)\s*\))?$/ ) ) {
+ if ( my ( $key, $value ) = ( $attr =~ /^(.*?)(?:\(\s*(.+?)\s*\))?$/ ) )
+ {
if ( defined $value ) {
( $value =~ s/^'(.*)'$/$1/ ) || ( $value =~ s/^"(.*)"/$1/ );
return \%attributes;
}
-=head1 NAME
-
-Catalyst::Base - Catalyst Controller Base Class
-
-=head1 SYNOPSIS
-
-
-=head1 DESCRIPTION
-
-
-=head1 METHODS
-
-=over 4
-
-=back
-
=head1 SEE ALSO
-L<Catalyst>.
+L<Catalyst>, L<Catalyst::Controller>.
=head1 AUTHOR