[Jifty-commit] r2779 - in jifty/branches/virtual-models: lib/Jifty

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat Feb 10 18:59:19 EST 2007


Author: jesse
Date: Sat Feb 10 18:59:19 2007
New Revision: 2779

Modified:
   jifty/branches/virtual-models/   (props changed)
   jifty/branches/virtual-models/lib/Jifty/Handle.pm

Log:
 r21971 at hualien:  jesse | 2007-02-10 18:22:42 -0500
  * extract "add uuid" to its own method


Modified: jifty/branches/virtual-models/lib/Jifty/Handle.pm
==============================================================================
--- jifty/branches/virtual-models/lib/Jifty/Handle.pm	(original)
+++ jifty/branches/virtual-models/lib/Jifty/Handle.pm	Sat Feb 10 18:59:19 2007
@@ -223,20 +223,32 @@
 sub insert {
     my $self  = shift;
     my $table = shift;
-    my %attrs = @_;
-    my $uuid  = delete($attrs{__uuid});
+    my %args = (@_);
+    my $uuid  = delete($args{__uuid});
 
-    my $rv = $self->SUPER::insert($table, %attrs);
+    my $rv = $self->SUPER::insert($table, %args);
 
     if ($rv) {
+        $self->_insert_uuid( table => $table, id => $rv, uuid => $uuid);
+
+    }
+
+    return $rv;
+}
+
+
+sub _insert_uuid {
+    my $self = shift;
+    my %args = (table => undef,
+                id => undef,
+                uuid => undef,
+                @_);
         # Generate a UUID on the sideband: $table - $rv - UUID.
         $self->dbh->do(
             qq[ INSERT INTO _jifty_uuids VALUES (?, ?, ?) ], {},
-            ($uuid || Jifty::Util->generate_uuid), $table, $rv
+            ($args{uuid} || Jifty::Util->generate_uuid), $args{table}, $args{id}
         );
-    }
 
-    return $rv;
 }
 
 =head2 bootstrap_uuid_table 
@@ -274,9 +286,7 @@
 
 sub lookup_uuid {
     my ($self, $table, $id) = @_;
-    my ($uuid) = $self->fetch_result(qq[
-        SELECT uuid FROM _jifty_uuids WHERE row_table = ? AND row_id = ?
-    ], $table, $id);
+    my ($uuid) = $self->fetch_result(qq[ SELECT uuid FROM _jifty_uuids WHERE row_table = ? AND row_id = ?  ], $table, $id);
     return $uuid;
 }
 


More information about the Jifty-commit mailing list