[Rt-commit] r4015 - DBIx-SearchBuilder/trunk

jesse at bestpractical.com jesse at bestpractical.com
Wed Nov 2 11:38:57 EST 2005


Author: jesse
Date: Wed Nov  2 11:38:55 2005
New Revision: 4015

Modified:
   DBIx-SearchBuilder/trunk/   (props changed)
   DBIx-SearchBuilder/trunk/Changes
   DBIx-SearchBuilder/trunk/SearchBuilder.pm
Log:
 r18095 at truegrounds:  jesse | 2005-11-02 22:31:27 -0500
 * Clone patch from ruz


Modified: DBIx-SearchBuilder/trunk/Changes
==============================================================================
--- DBIx-SearchBuilder/trunk/Changes	(original)
+++ DBIx-SearchBuilder/trunk/Changes	Wed Nov  2 11:38:55 2005
@@ -1,5 +1,9 @@
 Revision history for Perl extension DBIx::SearchBuilder.
 
+1.34 Wed Nov  2 22:26:15 EST 2005
+
+* Clone support from Ruslan
+
 1.33 Thu Sep 22 14:27:46 EDT 2005
 
 * Better SQL statement logging from alex

Modified: DBIx-SearchBuilder/trunk/SearchBuilder.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder.pm	(original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder.pm	Wed Nov  2 11:38:55 2005
@@ -2,9 +2,11 @@
 package DBIx::SearchBuilder;
 
 use strict;
+
 use vars qw($VERSION);
+$VERSION = "1.34";
 
-$VERSION = "1.33";
+use Clone qw();
 
 =head1 NAME
 
@@ -149,7 +151,49 @@
 
     #we have no limit statements. DoSearch won't work.
     $self->_isLimited(0);
+}
+
+=head2 Clone
+
+Returns copy of the current object with all search restrictions.
+
+=cut
+
+sub Clone
+{
+    my $self = shift;
+
+    my $obj = bless {}, ref($self);
+    %$obj = %$self;
 
+    delete $obj->{$_} for qw(
+        items
+    );
+    $obj->{'must_redo_search'} = 1;
+    $obj->{'itemscount'}       = 0;
+    
+    $obj->{$_} = Clone::clone($obj->{$_}) for ( $self->_ClonedAttributes );
+    return $obj;
+}
+
+=head2 _ClonedAttributes
+
+Returns list of the object's fields that should be copied.
+
+If your subclass store references in the object that should be copied while
+clonning then you probably want override this method and add own values to
+the list.
+
+=cut
+
+sub _ClonedAttributes
+{
+    return qw(
+        aliases
+        left_joins
+        subclauses
+        restrictions
+    );
 }
 
 


More information about the Rt-commit mailing list