allow ::Namespace shortcut to be used in controller role applications
Robert 'phaylon' Sedlacek [Sun, 16 Aug 2009 02:09:37 +0000 (04:09 +0200)]
Changes
examples/MyApp-Web/lib/MyApp/Web/Controller/Root.pm
examples/MyApp-Web/t/01app.t
lib/CatalystX/Declare/Keyword/Controller.pm

diff --git a/Changes b/Changes
index b28b51c..e4353cd 100644 (file)
--- 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
index 3f2e3d6..8d27d80 100644 (file)
@@ -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 => '');
index b929013..e5c12da 100644 (file)
@@ -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' }
 
index da2020a..4e9d26b 100644 (file)
@@ -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(