X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FDispatcher.pm;h=ec62c1fb0cf352f60483443c6c4134af87b7a507;hb=9779c885c17ff277c42aea35bd95f48284ae502f;hp=5a975ed7ef14acad683fd7bd557e980e2df90156;hpb=f87b7c218042591dace942198aed7939f1782dfb;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 5a975ed..ec62c1f 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -34,17 +34,14 @@ has _registered_dispatch_types => (is => 'rw', default => sub { {} }, required = has _method_action_class => (is => 'rw', default => 'Catalyst::Action'); has _action_hash => (is => 'rw', required => 1, lazy => 1, default => sub { {} }); has _container_hash => (is => 'rw', required => 1, lazy => 1, default => sub { {} }); -has preload_dispatch_types => (is => 'rw', required => 1, lazy => 1, default => sub { [@PRELOAD] }); -has postload_dispatch_types => (is => 'rw', required => 1, lazy => 1, default => sub { [@POSTLOAD] }); - -# Wrap accessors so you can assign a list and it will capture a list ref. -around qw/preload_dispatch_types postload_dispatch_types/ => sub { - my $orig = shift; - my $self = shift; - return $self->$orig([@_]) if (scalar @_ && ref $_[0] ne 'ARRAY'); - return $self->$orig(@_); -}; +my %dispatch_types = ( pre => \@PRELOAD, post => \@POSTLOAD ); +foreach my $type (keys %dispatch_types) { + has $type . "load_dispatch_types" => ( + is => 'rw', required => 1, lazy => 1, default => sub { $dispatch_types{$type} }, + traits => ['MooseX::Emulate::Class::Accessor::Fast::Meta::Role::Attribute'], # List assignment is CAF style + ); +} =head1 NAME @@ -680,7 +677,7 @@ of course it's being used.) sub dispatch_type { my ($self, $name) = @_; - + # first param is undef because we cannot get the appclass $name = Catalyst::Utils::resolve_namespace(undef, 'Catalyst::DispatchType', $name);