s/snippets/captures/
Yuval Kogman [Wed, 10 May 2006 20:40:24 +0000 (20:40 +0000)]
lib/Catalyst.pm
lib/Catalyst/DispatchType/Regex.pm
lib/Catalyst/Manual/Intro.pod
lib/Catalyst/Request.pm

index 755a9ab..247a79d 100644 (file)
@@ -164,7 +164,7 @@ Catalyst - The Elegant MVC Web Application Framework
     sub details : Regex('^product/(\w+)/details$') {
         my ( $self, $c ) = @_;
         # extract the (\w+) from the URI
-        my $product = $c->req->snippets->[0];
+        my $product = $c->req->captures->[0];
     }
 
 See L<Catalyst::Manual::Intro> for additional information.
@@ -867,7 +867,7 @@ sub uri_for {
     my $basepath = $base->path;
     $basepath =~ s/\/$//;
     $basepath .= '/';
-    my $namespace = $c->namespace;
+    my $namespace = $c->namespace || '';
 
     # massage namespace, empty if absolute path
     $namespace =~ s/^\///;
@@ -1495,7 +1495,7 @@ sub prepare {
                     parameters       => {},
                     query_parameters => {},
                     secure           => 0,
-                    snippets         => [],
+                    captures         => [],
                     uploads          => {}
                 }
             ),
index 9470297..4a27801 100644 (file)
@@ -48,11 +48,11 @@ sub match {
     # Check path against plain text first
 
     foreach my $compiled ( @{ $self->{compiled} || [] } ) {
-        if ( my @snippets = ( $path =~ $compiled->{re} ) ) {
+        if ( my @captures = ( $path =~ $compiled->{re} ) ) {
             next unless $compiled->{action}->match($c);
             $c->req->action( $compiled->{path} );
             $c->req->match($path);
-            $c->req->snippets( \@snippets );
+            $c->req->captures( \@captures );
             $c->action( $compiled->{action} );
             $c->namespace( $compiled->{action}->namespace );
             return 1;
index 26491e2..561956e 100644 (file)
@@ -373,9 +373,9 @@ http://localhost:3000/catalog/foo/widget23 as well.
 
 For both LocalRegex and Regex actions, if you use capturing parentheses
 to extract values within the matching URL, those values are available in
-the C<$c-E<gt>req-E<gt>snippets> array. In the above example, "widget23"
+the C<$c-E<gt>req-E<gt>captures> array. In the above example, "widget23"
 would capture "23" in the above example, and
-C<$c-E<gt>req-E<gt>snippets-E<gt>[0]> would be "23". If you want to pass
+C<$c-E<gt>req-E<gt>captures-E<gt>[0]> would be "23". If you want to pass
 arguments at the end of your URL, you must use regex action keys. See
 L</URL Path Handling> below.
 
index d8ead36..99035b3 100644 (file)
@@ -10,7 +10,7 @@ use URI::QueryParam;
 
 __PACKAGE__->mk_accessors(
     qw/action address arguments cookies headers match method
-      protocol query_parameters secure snippets uri user/
+      protocol query_parameters secure captures uri user/
 );
 
 *args         = \&arguments;
@@ -19,6 +19,7 @@ __PACKAGE__->mk_accessors(
 *params       = \&parameters;
 *query_params = \&query_parameters;
 *path_info    = \&path;
+*snippets     = \&captures;
 
 sub content_encoding { shift->headers->content_encoding(@_) }
 sub content_length   { shift->headers->content_length(@_) }
@@ -61,7 +62,7 @@ Catalyst::Request - provides information about the current client request
     $req->read;
     $req->referer;
     $req->secure;
-    $req->snippets;
+    $req->captures; # previously knows as snippets
     $req->upload;
     $req->uploads;
     $req->uri;
@@ -407,11 +408,16 @@ Shortcut for $req->headers->referer. Returns the referring page.
 
 Returns true or false, indicating whether the connection is secure (https).
 
-=head2 $req->snippets
+=head2 $req->captures
+
+Returns a reference to an array containing regex captures.
 
-Returns a reference to an array containing regex snippets.
+    my @captures = @{ $c->request->captures };
+
+=head2 $req->snippets
 
-    my @snippets = @{ $c->request->snippets };
+C<captures> used to be called snippets. This is still available for backwoards
+compatibility, but is considered deprecated.
 
 =head2 $req->upload