bumped version
[catagits/CatalystX-Declare.git] / lib / CatalystX / Declare / Keyword / Role.pm
index 28b11f8..6220562 100644 (file)
@@ -5,23 +5,42 @@ class CatalystX::Declare::Keyword::Role
 
 
     use aliased 'MooseX::MethodAttributes::Role::Meta::Role';
-    use aliased 'CatalystX::Declare::Keyword::Action', 'ActionKeyword';
+    use aliased 'MooseX::Role::Parameterized::Meta::Role::Parameterizable';
+    use aliased 'CatalystX::Declare::Keyword::Action',  'ActionKeyword';
 
 
+    around import_symbols_from (Object $ctx) {
+
+        $ctx->has_parameter_signature
+        ? $self->$orig($ctx)
+        : sprintf('Moose::Role -traits => q(MethodAttributes),')
+    }
+
     before add_namespace_customizations (Object $ctx, Str $package) {
 
+        my $source  = $self->import_symbols_from($ctx);
+        my @symbols = $self->imported_moose_symbols;
+
         $ctx->add_preamble_code_parts(
             'use CLASS',
-            'use Moose::Role -traits => q(MethodAttributes)',
         );
     }
 
-    around default_inner () {
+    after add_namespace_customizations (Object $ctx, Str $package) {
+
+        $ctx->add_preamble_code_parts(
+            sprintf(
+                'use %s -traits => q(%s), qw( has )',
+                'MooseX::Role::Parameterized',
+                'MooseX::MethodAttributes::Role::Meta::Role',
+            ),
+        ) if $ctx->has_parameter_signature;
+    }
 
-        my @modifiers = qw( );
+    around default_inner (@args) {
 
         return [ 
-            ( grep { my $id = $_->identifier; not grep { $id eq $_ } @modifiers } @{ $self->$orig() || [] } ),
+            @{ $self->$orig(@args) },
             ActionKeyword->new(identifier => 'action'),
             ActionKeyword->new(identifier => 'under'),
             ActionKeyword->new(identifier => 'final'),
@@ -39,7 +58,7 @@ CatalystX::Declare::Keyword::Role - Declare Catalyst Controller Roles
 
     use CatalystX::Declare;
 
-    component_role MyApp::Web::ControllerRole::Foo {
+    controller_role MyApp::Web::ControllerRole::Foo {
 
         method provided_method { ... }
 
@@ -50,7 +69,7 @@ CatalystX::Declare::Keyword::Role - Declare Catalyst Controller Roles
 
 =head1 DESCRIPTION
 
-This handler provides the C<component_role> keyword. It is an extension of the
+This handler provides the C<controller_role> keyword. It is an extension of the
 L<MooseX::Declare::Syntax::Keyword::Role> handler. Like with declared 
 controllers, the C<method> keyword and the modifiers are provided. For details
 on the syntax for action declarations have a look at