From: Robert 'phaylon' Sedlacek Date: Sun, 16 Aug 2009 02:09:37 +0000 (+0200) Subject: allow ::Namespace shortcut to be used in controller role applications X-Git-Tag: 0.007~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f00bea98e5a87cf38a8f3e3048cdf8cde766510e;hp=dae0432951a732f9ed379033194a65861d3cb3e2;p=catagits%2FCatalystX-Declare.git allow ::Namespace shortcut to be used in controller role applications --- diff --git a/Changes b/Changes index b28b51c..e4353cd 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,6 @@ [0.007] ... + - used namespace keyword in examples + - allow namespace shorcuts in controller role application [0.006] Sun Aug 16 03:43:10 CEST 2009 - fixed keyword listing method to use new MXD around diff --git a/examples/MyApp-Web/lib/MyApp/Web/Controller/Root.pm b/examples/MyApp-Web/lib/MyApp/Web/Controller/Root.pm index 3f2e3d6..8d27d80 100644 --- a/examples/MyApp-Web/lib/MyApp/Web/Controller/Root.pm +++ b/examples/MyApp-Web/lib/MyApp/Web/Controller/Root.pm @@ -1,9 +1,11 @@ use CatalystX::Declare; +namespace MyApp::Web; + # we consume a role that does what the RenderView action class # would normally do -controller MyApp::Web::Controller::Root - with MyApp::Web::ControllerRole::RenderView { +controller ::Controller::Root + with ::ControllerRole::RenderView { # $CLASS is provided by CLASS.pm $CLASS->config(namespace => ''); diff --git a/examples/MyApp-Web/t/01app.t b/examples/MyApp-Web/t/01app.t index b929013..e5c12da 100644 --- a/examples/MyApp-Web/t/01app.t +++ b/examples/MyApp-Web/t/01app.t @@ -5,6 +5,7 @@ use Test::More tests => 2; use FindBin; use lib "$FindBin::Bin/../lib"; +use lib "$FindBin::Bin/../../../lib"; BEGIN { use_ok 'Catalyst::Test', 'MyApp::Web' } diff --git a/lib/CatalystX/Declare/Keyword/Controller.pm b/lib/CatalystX/Declare/Keyword/Controller.pm index da2020a..4e9d26b 100644 --- a/lib/CatalystX/Declare/Keyword/Controller.pm +++ b/lib/CatalystX/Declare/Keyword/Controller.pm @@ -53,11 +53,13 @@ class CatalystX::Declare::Keyword::Controller method add_with_option_customizations (Object $ctx, $package, ArrayRef $roles, HashRef $options) { + $package = $ctx->qualify_namespace($package); + $ctx->add_cleanup_code_parts( map { sprintf('Class::MOP::load_class(%s)', pp "$_"), sprintf('%s->meta->apply(%s->meta)', $_, $package), - } @$roles + } map { $ctx->qualify_namespace($_) } @$roles ); $ctx->add_cleanup_code_parts(