[Catalyst-commits] r10703 - Catalyst-Runtime/5.80/trunk/lib/Catalyst

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Sun Jun 28 16:58:04 GMT 2009


Author: t0m
Date: 2009-06-28 16:58:01 +0000 (Sun, 28 Jun 2009)
New Revision: 10703

Modified:
   Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm
Log:
Twinking. That around modifier offended me, as I wrote the code to inline accessors like that..

Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm	2009-06-28 16:54:40 UTC (rev 10702)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm	2009-06-28 16:58:01 UTC (rev 10703)
@@ -34,18 +34,15 @@
 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] });
+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
+    );
+}
 
-# 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(@_);
-};
-
 =head1 NAME
 
 Catalyst::Dispatcher - The Catalyst Dispatcher




More information about the Catalyst-commits mailing list