X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FBase.pm;h=1b672f0941861f385536bb39f9b2d1c42b749b2c;hb=245ae014f237e59c7b9f0596c6dddf19593512fa;hp=6a97984b6d42e3fe90e49fd9af8195436af4a467;hpb=ae6c0d3f9cac342e26e7c8df45dda3ba3b631a87;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Base.pm b/lib/Catalyst/Base.pm index 6a97984..1b672f0 100644 --- a/lib/Catalyst/Base.pm +++ b/lib/Catalyst/Base.pm @@ -8,9 +8,10 @@ use Catalyst::Utils; 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 ) = @_; @@ -42,7 +43,9 @@ sub _AUTO : Private { sub _ACTION : Private { my ( $self, $c ) = @_; - $c->action->execute($c); + if ( ref $c->action && $c->action->isa('Catalyst::Action') ) { + $c->action->execute($c); + } return !@{ $c->error }; } @@ -54,6 +57,26 @@ sub _END : Private { return !@{ $c->error }; } +=head1 NAME + +Catalyst::Base - Catalyst Base Class + +=head1 SYNOPSIS + +See L + +=head1 DESCRIPTION + +Catalyst Base Class + +=head1 METHODS + +=over 4 + +=item $self->action_namespace($c) + +=cut + sub action_namespace { my ( $self, $c ) = @_; return Catalyst::Utils::class2prefix( ref $self, @@ -61,6 +84,10 @@ sub action_namespace { || ''; } +=item $self->register_actions($c) + +=cut + sub register_actions { my ( $self, $c ) = @_; my $class = ref $self || $self; @@ -92,7 +119,7 @@ sub register_actions { next; } my $reverse = $namespace ? "$namespace/$method" : $method; - my $action = Catalyst::Action->new( + my $action = $self->_action_class->new( { name => $method, code => $code, @@ -113,7 +140,8 @@ sub _parse_attrs { # 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/ ); @@ -124,25 +152,11 @@ sub _parse_attrs { return \%attributes; } -=head1 NAME - -Catalyst::Base - Catalyst Controller Base Class - -=head1 SYNOPSIS - - -=head1 DESCRIPTION - - -=head1 METHODS - -=over 4 - =back =head1 SEE ALSO -L. +L, L. =head1 AUTHOR