refactor of namespace handling
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Utils.pm
index 4d5f0ed..76f0733 100644 (file)
@@ -9,6 +9,8 @@ use URI;
 use Carp qw/croak/;
 use Cwd;
 
+use String::RewritePrefix;
+
 use namespace::clean;
 
 =head1 NAME
@@ -377,6 +379,27 @@ sub term_width {
     return $_term_width = $width;
 }
 
+
+=head2 resolve_namespace
+
+Method which adds the namespace for plugins and actions.
+
+  __PACKAGE__->setup(qw(MyPlugin));
+  
+  # will load Catalyst::Plugin::MyPlugin
+
+=cut
+
+
+sub resolve_namespace {
+    my $namespace = shift;
+    my @classes = @_;
+    return String::RewritePrefix->rewrite(
+        { '' => $namespace.'::', '+' => '' }, @classes,
+      );
+}
+
+
 =head1 AUTHORS
 
 Catalyst Contributors, see Catalyst.pm