refactor of namespace handling
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Dispatcher.pm
index c06c2a4..5df4526 100644 (file)
@@ -643,9 +643,8 @@ sub _load_dispatch_types {
 
     # Preload action types
     for my $type (@types) {
-        my $class =
-          ( $type =~ /^\+(.*)$/ ) ? $1 : "Catalyst::DispatchType::${type}";
-
+        my $class = Catalyst::Utils::resolve_namespace('Catalyst::DispatchType', $type);
+        
         eval { Class::MOP::load_class($class) };
         Catalyst::Exception->throw( message => qq/Couldn't load "$class"/ )
           if $@;
@@ -668,9 +667,7 @@ of course it's being used.)
 sub dispatch_type {
     my ($self, $name) = @_;
 
-    unless ($name =~ s/^\+//) {
-        $name = "Catalyst::DispatchType::" . $name;
-    }
+    $name = Catalyst::Utils::resolve_namespace('Catalyst::DispatchType', $name);
 
     for (@{ $self->_dispatch_types }) {
         return $_ if ref($_) eq $name;
@@ -707,7 +704,6 @@ foreach my $public_method_name (qw/
         my %package_hash; # Only warn once per method, per package. These are infrequent enough that
                           # I haven't provided a way to disable them, patches welcome.
         $meta->add_before_method_modifier($public_method_name, sub {
-            my $class = blessed(shift);
             my $class = caller(2);
             chomp($class);
             $package_hash{$class}++ || do {