[Jifty-commit] r1663 - jifty/trunk/lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Jul 24 19:04:14 EDT 2006


Author: audreyt
Date: Mon Jul 24 19:04:13 2006
New Revision: 1663

Modified:
   jifty/trunk/lib/Jifty/Web.pm

Log:
* Jifty->web->return in void context is now an immediate return.

Modified: jifty/trunk/lib/Jifty/Web.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web.pm	(original)
+++ jifty/trunk/lib/Jifty/Web.pm	Mon Jul 24 19:04:13 2006
@@ -726,13 +726,16 @@
 
 =head3 return PARAMHASH
 
-Generates and renders a L<Jifty::Web::Form::Clickable> using the given
-I<PARAMHASH>, additionally defaults to calling the current
-continuation.
+If called in non-void context, creates and renders a
+L<Jifty::Web::Form::Clickable> using the given I<PARAMHASH>,
+additionally defaults to calling the current continuation.
 
 Takes an additional argument, C<to>, which can specify a default path
 to return to if there is no current continuation.
 
+In void context, does a redirect to the URL that the
+L<Jifty::Web::Form::Clickable> object generates.
+
 =cut
 
 sub return {
@@ -740,11 +743,22 @@
     my %args = (@_);
     my $continuation = Jifty->web->request->continuation;
     if (not $continuation and $args{to}) {
-        $continuation = Jifty::Continuation->new(request => Jifty::Request->new(path => $args{to}));
+        $continuation = Jifty::Continuation->new(
+            request => Jifty::Request->new(path => $args{to})
+        );
     }
     delete $args{to};
 
-    $self->link( call => $continuation, %args );
+    my $clickable = Jifty::Web::Form::Clickable->new(
+        call => $continuation, %args
+    );
+
+    if ( defined wantarray ) {
+        return $clickable->generate;
+    }
+    else {
+        $self->redirect($clickable);
+    }
 }
 
 =head3 render_messages [MONIKER]


More information about the Jifty-commit mailing list