X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FUtils.pm;h=05248fc5824af0e647ee7637260ed917cd715afa;hb=c77865585f68f34422f7a6eacf2fa901531f05d9;hp=f47909d39fc8c874d61b971764fe5e6fcea08aff;hpb=b0ad47c12a21862b08d8e2942095065ac2f7edf2;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Utils.pm b/lib/Catalyst/Utils.pm index f47909d..05248fc 100644 --- a/lib/Catalyst/Utils.pm +++ b/lib/Catalyst/Utils.pm @@ -9,6 +9,8 @@ use URI; use Carp qw/croak/; use Cwd; +use String::RewritePrefix; + use namespace::clean; =head1 NAME @@ -377,6 +379,33 @@ 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 $appnamespace = shift; + my $namespace = shift; + my @classes = @_; + return String::RewritePrefix->rewrite({ + q[] => qq[${namespace}::], + q[+] => q[], + (defined $appnamespace + ? (q[~] => qq[${appnamespace}::]) + : () + ), + }, @classes); +} + + =head1 AUTHORS Catalyst Contributors, see Catalyst.pm