all roles are now applied at once
Robert 'phaylon' Sedlacek [Sun, 11 Oct 2009 17:59:29 +0000 (19:59 +0200)]
Changes
lib/CatalystX/Declare/Keyword/Controller.pm

diff --git a/Changes b/Changes
index b5292df..9b616d4 100644 (file)
--- a/Changes
+++ b/Changes
@@ -7,6 +7,7 @@
     - dispatch type mutabilisation for manipulation now done more
       sanely (Tomas Doran).
     - fixed M:I requirement handling for authors.
+    - controller roles are now applied all at once (Tomas Doran).
 
 [0.010] Sun Sep 13 15:52:01 CEST 2009
     - Fix Compat with MooseX::Method::Signatures >=0.22 ( KENTNL )
index 8d8aaca..d625dab 100644 (file)
@@ -55,12 +55,10 @@ class CatalystX::Declare::Keyword::Controller
 
         $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),
-            } map { $ctx->qualify_namespace($_) } @$roles
-        );
+        $ctx->add_cleanup_code_parts('Moose::Util::apply_all_roles("' . $package . '", qw/'
+            . join(' ', map { $ctx->qualify_namespace($_) } @$roles)
+            . '/)')
+            if scalar @$roles;
 
         $ctx->add_cleanup_code_parts(
             sprintf '%s->meta->make_immutable', $package
@@ -153,9 +151,7 @@ controllers.
     )
 
 This hook method will be called by L<MooseX::Declare> when C<with> options were
-encountered. It will load the specified class and apply them to the controller
-one at a time. This will change in the future, and they will be all applied 
-together.
+encountered. Since 0.011 the roles will be applied all at once.
 
 This method will also add a callback to make the controller immutable to the
 cleanup code parts unless C<is mutable> was specified.