[Jifty-commit] r4636 - in jifty/trunk: lib/Jifty/Action

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Dec 7 01:03:33 EST 2007


Author: jesse
Date: Fri Dec  7 01:03:32 2007
New Revision: 4636

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/lib/Jifty/Action/Record.pm

Log:
 r72784 at pinglin:  jesse | 2007-12-07 01:03:22 -0500
 * defer default value until we really care about it


Modified: jifty/trunk/lib/Jifty/Action/Record.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action/Record.pm	(original)
+++ jifty/trunk/lib/Jifty/Action/Record.pm	Fri Dec  7 01:03:32 2007
@@ -21,7 +21,7 @@
 =cut
 
 use base qw/Jifty::Action/;
-
+use Scalar::Defer qw/ defer /;
 use Scalar::Util qw/ blessed /;
 use Clone qw/clone/;
 
@@ -161,11 +161,21 @@
     for my $field (keys %$arguments) {
             # Load the column object and the record's current value
             next unless my $function = $self->record->can($field);
-            my $current_value = $function->($self->record);
 
-            # If the current value is actually a pointer to
-            # another object, turn it into an ID
-            $current_value = $current_value->id if blessed($current_value) and $current_value->isa('Jifty::Record');
+
+
+            my $current_value = defer {
+                my $val = $function->( $self->record );
+
+                # If the current value is actually a pointer to
+                # another object, turn it into an ID
+                $val = $val->id
+                    if blessed($val)
+                        and $val->isa('Jifty::Record');
+
+                return $val;
+            };
+
 
             # The record's current value becomes the widget's default value
             $arguments->{$field}->{default_value} = $current_value if $self->record->id;


More information about the Jifty-commit mailing list