[siesta-commit] siesta/lib/Siesta/Storage DBI.pm,1.30,1.31

[prev] [thread] [next] [lurker] [Date index for 2002/09/17]

From: clampr
Subject: [siesta-commit] siesta/lib/Siesta/Storage DBI.pm,1.30,1.31
Date: 12:31 on 17 Sep 2002
Update of /cvsroot/siesta/siesta/lib/Siesta/Storage
In directory usw-pr-cvs1:/tmp/cvs-serv2193/lib/Siesta/Storage

Modified Files:
	DBI.pm 
Log Message:
perltidy

Index: DBI.pm
===================================================================
RCS file: /cvsroot/siesta/siesta/lib/Siesta/Storage/DBI.pm,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- DBI.pm	15 Sep 2002 12:46:07 -0000	1.30
+++ DBI.pm	17 Sep 2002 11:31:55 -0000	1.31
@@ -11,7 +11,7 @@
     my $class = shift;
     my $dbh   = DBI->connect(@_);
 
-    unless ($dbh && $_[0] =~ /:SQLite:/) {    # busy wait for SQLite
+    unless ( $dbh && $_[0] =~ /:SQLite:/ ) {    # busy wait for SQLite
         for ( 1 .. 10 ) {
             sleep 2;
             $dbh = DBI->connect(@_)
@@ -38,9 +38,10 @@
     my $dbh = $self->_dbh;
     my $sql = "SELECT " . join ( ', ', @columns ) . " FROM $args{table}";
 
-    $sql .= " WHERE " .
-      join ( ' AND ', map { "$_ = " . $dbh->quote( $where{$_} ) } keys %where )
-        if %where;
+    $sql .= " WHERE "
+      . join ( ' AND ',
+               map { "$_ = " . $dbh->quote( $where{$_} ) } keys %where )
+      if %where;
 
     return map {
         my %foo;
@@ -50,28 +51,29 @@
 }
 
 sub _update_or_insert {
-    my $self = shift;
-    my %args = @_;
-    my %where   = %{ $args{where} || {} };
-    my %row = %{ $args{row} };
-    my $dbh = $self->_dbh;
+    my $self  = shift;
+    my %args  = @_;
+    my %where = %{ $args{where} || {} };
+    my %row   = %{ $args{row} };
+    my $dbh   = $self->_dbh;
 
     my $sql;
-    if ( $self->_get_rows( %args, columns => [ keys %row ]) ) {
-        $sql = "UPDATE $args{table} SET " . join ( ', ', map {
-            "$_ = " . $dbh->quote( $row{$_} )
-        } keys %row );
+    if ( $self->_get_rows( %args, columns => [ keys %row ] ) ) {
+        $sql =
+          "UPDATE $args{table} SET "
+          . join ( ', ', map { "$_ = " . $dbh->quote( $row{$_} ) } keys %row );
 
-        $sql .= " WHERE ". join ( ' AND ', map {
-            "$_ = " . $dbh->quote( $where{$_} )
-        } keys %where )
+        $sql .= " WHERE "
+          . join ( ' AND ',
+                   map { "$_ = " . $dbh->quote( $where{$_} ) } keys %where )
           if %where;
     }
     else {
-        $sql = "INSERT INTO $args{table} (" . join(', ', keys %row) .
-          ") VALUES ( " . join ( ', ', map { 
-              $dbh->quote( $row{$_} )
-          } keys %row ) . " )";
+        $sql =
+          "INSERT INTO $args{table} ("
+          . join ( ', ', keys %row )
+          . ") VALUES ( "
+          . join ( ', ', map { $dbh->quote( $row{$_} ) } keys %row ) . " )";
     }
 
     $dbh->do($sql)
@@ -128,9 +130,11 @@
     my @fields = @Siesta::User::fields;
     my $sql;
 
-    $self->_update_or_insert( table => 'users',
+    $self->_update_or_insert(
+                              table => 'users',
                               where => { id => $user->id },
-                              row   => { map { $_ => $user->$_() } @fields } );
+                              row   => { map { $_ => $user->$_() } @fields }
+                              );
 }
 
 sub delete_user {
@@ -139,7 +143,7 @@
 
     $user = UNIVERSAL::can( $user, 'id' ) ? $user->id : $user;
 
-    return  $self->_dbh->do( qq{DELETE FROM users WHERE id = '$user'} );
+    return $self->_dbh->do(qq{DELETE FROM users WHERE id = '$user'});
 }
 
 sub load_list {
@@ -163,9 +167,11 @@
     return unless defined $list;
 
     my @fields = @Siesta::List::fields;
-    $self->_update_or_insert( table => 'lists',
+    $self->_update_or_insert(
+                              table => 'lists',
                               where => { id => $list->id },
-                              row   => { map { $_ => $list->$_() } @fields } );
+                              row   => { map { $_ => $list->$_() } @fields }
+                              );
 }
 
 sub delete_list {
@@ -174,8 +180,7 @@
 
     $list = UNIVERSAL::can( $list, 'id' ) ? $list->id : $list;
 
-    return $self->_dbh->do(
-        qq{DELETE FROM lists WHERE id = '$list'} );
+    return $self->_dbh->do(qq{DELETE FROM lists WHERE id = '$list'});
 }
 
 sub member_of_list {
@@ -201,7 +206,7 @@
     my $user = shift;
 
     $self->_dbh->do(
-                    qq{INSERT INTO list_users (list_id, user_id)
+        qq{INSERT INTO list_users (list_id, user_id)
                        VALUES ('$list', '$user')} )
       or die $self->_dbh->errstr;
     return 1;
@@ -263,8 +268,8 @@
 
     my ( $namespace, $user_id, $list_id, $key, $value ) = @_;
 
-    $user_id = UNIVERSAL::can($user_id, 'id') ? $user_id->id : $user_id;
-    $list_id = UNIVERSAL::can($list_id, 'id') ? $list_id->id : $list_id;
+    $user_id = UNIVERSAL::can( $user_id, 'id' ) ? $user_id->id : $user_id;
+    $list_id = UNIVERSAL::can( $list_id, 'id' ) ? $list_id->id : $list_id;
 
     # make suyre they're not undef
     $user_id ||= '';
@@ -281,17 +286,21 @@
     my $return =
       $self->get_config_explicitly( $namespace, $user_id, $list_id, $key );
 
-    $self->_update_or_insert( table => 'config',
-                              where => { namespace => $namespace,
-                                         user_id => $user_id,
-                                         list_id => $list_id,
-                                         key => $key },
-                              row =>   { namespace => $namespace,
-                                         user_id => $user_id,
-                                         list_id => $list_id,
-                                         key => $key,
-                                         value => $value
-                                       },
+    $self->_update_or_insert(
+                              table => 'config',
+                              where => {
+                                         namespace => $namespace,
+                                         user_id   => $user_id,
+                                         list_id   => $list_id,
+                                         key       => $key
+                              },
+                              row => {
+                                       namespace => $namespace,
+                                       user_id   => $user_id,
+                                       list_id   => $list_id,
+                                       key       => $key,
+                                       value     => $value
+                              },
                               );
 }
 



Generated at 13:57 on 01 Jul 2004 by mariachi 0.52