[rt-commit] [svn] r614 - in DBIx-SearchBuilder/trunk: .
SearchBuilder
robert at fsck.com
robert at fsck.com
Wed Mar 24 01:00:54 EST 2004
Author: robert
Date: Wed Mar 24 01:00:53 2004
New Revision: 614
Modified:
DBIx-SearchBuilder/trunk/ (props changed)
DBIx-SearchBuilder/trunk/SearchBuilder/Union.pm
Log:
----------------------------------------------------------------------
r90: rspier | 2004-03-24T06:00:43.432212Z
- update/cleanup documentation
- get rid of extraneous curp helper function
----------------------------------------------------------------------
Modified: DBIx-SearchBuilder/trunk/SearchBuilder/Union.pm
==============================================================================
--- DBIx-SearchBuilder/trunk/SearchBuilder/Union.pm (original)
+++ DBIx-SearchBuilder/trunk/SearchBuilder/Union.pm Wed Mar 24 01:00:53 2004
@@ -12,7 +12,6 @@
# DBIx::SearchBuilder::Collection to contain all the iterator logic.
# This could inherit from that.
-
=head1 NAME
DBIx::Searchbuilder::Union - Deal with multiple SearchBuilder result sets as one
@@ -24,6 +23,15 @@
$U->add( $tickets1 );
$U->add( $tickets2 );
+ $U->GotoFirstItem;
+ while (my $z = $U->Next) {
+ printf "%5d %30.30s\n", $z->Id, $z->Subject;
+ }
+
+=head1 WARNING
+
+This module is still experimental.
+
=head1 DESCRIPTION
Implements a subset of the DBIx::SearchBuilder collection methods, but
@@ -31,12 +39,6 @@
the results of two unrelated searches (for the same kind of objects)
in a single list.
-=head1 AUTHOR
-
- Robert Spier
-
-=cut
-
=head1 METHODS
=head2 new
@@ -54,11 +56,6 @@
}, shift;
}
-# private
-sub curp {
- shift->{curp}
-}
-
=head2 add $sb
Add a searchbuilder result (collection) to the Union object.
@@ -108,14 +105,14 @@
sub Next {
my $self=shift;
- return undef unless defined $self->{data}[ $self->curp ];
+ return undef unless defined $self->{data}[ $self->{curp} ];
- my $cur = $self->{data}[ $self->curp ];
+ my $cur = $self->{data}[ $self->{curp} ];
if ( $cur->_ItemsCounter == $cur->Count ) {
# move to the next element
$self->{curp}++;
- return undef unless defined $self->{data}[ $self->curp ];
- $cur = $self->{data}[ $self->curp ];
+ return undef unless defined $self->{data}[ $self->{curp} ];
+ $cur = $self->{data}[ $self->{curp} ];
$self->{data}[ $self->{curp} ]->GotoFirstItem;
}
$self->{item}++;
@@ -135,10 +132,17 @@
return ( $self->Next );
}
+=head2 Count
+
+Returns the total number of elements in the Union'ed Collection
+
+=cut
+
sub Count {
my $self = shift;
my $sum = 0;
+ # cache the results
return $self->{count} if defined $self->{count};
$sum += $_->Count for (@{$self->{data}});
@@ -210,8 +214,20 @@
return \@ret;
}
+=head1 AUTHOR
+Copyright (c) 2004 Robert Spier
+All rights reserved.
+
+This library is free software; you can redistribute it
+and/or modify it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+DBIx::SearchBuilder
+
+=cut
1;
More information about the Rt-commit
mailing list