X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FBase.pm;h=e2bf41ac9d6819dd44443925f7645aba2b5a94fc;hb=1143712c6bec3492444f03a91fde0ce081d9540a;hp=789c6ab9f987b41334456a1761e787f5c9e36946;hpb=a2f2cde95194a17fe2401ae58c92b5494bac599f;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Base.pm b/lib/Catalyst/Base.pm index 789c6ab..e2bf41a 100644 --- a/lib/Catalyst/Base.pm +++ b/lib/Catalyst/Base.pm @@ -1,24 +1,56 @@ package Catalyst::Base; use strict; -use base qw/Class::Data::Inheritable Class::Accessor::Fast/; +use base qw/Catalyst::AttrContainer Class::Accessor::Fast/; use Catalyst::Exception; use NEXT; -__PACKAGE__->mk_classdata($_) for qw/_attr_cache _action_cache _config/; -__PACKAGE__->_attr_cache( {} ); -__PACKAGE__->_action_cache( [] ); +__PACKAGE__->mk_classdata($_) for qw/_config _dispatch_steps/; -# note - see attributes(3pm) -sub MODIFY_CODE_ATTRIBUTES { - my ( $class, $code, @attrs ) = @_; - $class->_attr_cache->{$code} = [@attrs]; - push @{ $class->_action_cache }, [ $code, [@attrs] ]; - return (); +__PACKAGE__->_dispatch_steps([ qw/_BEGIN _AUTO _ACTION/ ]); + +sub _DISPATCH :Private { + my ( $self, $c ) = @_; + + foreach my $disp (@{$self->_dispatch_steps}) { + last unless $c->forward($disp); + } + + $c->forward('_END'); } -sub FETCH_CODE_ATTRIBUTES { $_[0]->_attr_cache->{ $_[1] } || () } +sub _BEGIN :Private { + my ( $self, $c ) = @_; + my $begin = @{ $c->get_action('begin', $c->namespace, 1) }[-1]; + return 1 unless $begin; + $begin->[0]->execute($c); + return !@{$c->error}; +} + +sub _AUTO :Private { + my ( $self, $c ) = @_; + my @auto = @{ $c->get_action('auto', $c->namespace, 1) }; + foreach my $auto (@auto) { + $auto->[0]->execute($c); + return 0 unless $c->state; + } + return 1; +} + +sub _ACTION :Private { + my ( $self, $c ) = @_; + $c->action->execute($c); + return !@{$c->error}; +} + +sub _END :Private { + my ( $self, $c ) = @_; + my $end = @{ $c->get_action('end', $c->namespace, 1) }[-1]; + return 1 unless $end; + $end->[0]->execute($c); + return !@{$c->error}; +} =head1 NAME @@ -126,6 +158,7 @@ L. Sebastian Riedel, C Marcus Ramberg, C +Matt S Trout, C =head1 COPYRIGHT