better docs for params and complex string test
Robert 'phaylon' Sedlacek [Fri, 18 Sep 2009 01:30:19 +0000 (03:30 +0200)]
lib/CatalystX/Declare/Keyword/Role.pm
t/022_parameterized_roles.t
t/lib/TestApp/ControllerRole/Parameterized.pm

index cd31eac..5e40ac1 100644 (file)
@@ -94,6 +94,19 @@ apply the controller role in the L</SYNOPSIS>, you'd use code like this:
         action base under '/' as '';
     }
 
+You can currently only use the parameters in action declarations in the body,
+the C<as> path part and the C<under> base action specification:
+
+    controller_role Foo (Str :$base, Str :$part) {
+
+        action foo under $base as $part { ... }
+    }
+
+You can specify the parameters either as plain scalar variables or as quoted
+strings. The latter is especially useful for more complex path parts:
+
+    action foo under $base as "$pathpart/fnord" { ... }
+
 =head1 SUPERCLASSES
 
 =over
index 6cdadc8..531b2cb 100644 (file)
@@ -12,5 +12,6 @@ is get('/param/greet'), 'foo:foo', 'parameterized role was consumed correctly';
 is get('/param/somebase/dynabase'), 'under somebase', 'dynamic base via parameter';
 is get('/param/somebase/somepart'), 'under somebase as somepart', 'dynamic base and path part via parameter';
 is get('/param/somebase/scoped'), 'scoped under somebase', 'dynamic base in under scope via parameter';
+is get('/param/somebase/somepart/deep'), 'somepart/deep under somebase', 'more complex strings';
 
 done_testing;
index 10ffc62..d4e4b11 100644 (file)
@@ -21,5 +21,9 @@ controller_role TestApp::ControllerRole::Parameterized (Str :$message, Str :$bas
         final action scoped {
             $ctx->response->body( "scoped under $base" );
         }
+
+        final action complex as "$part/deep" {
+            $ctx->response->body( "$part/deep under $base" );
+        }
     }
 }