Move CDBI code out of the main ResultSet implementation
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / CDBICompat / Iterator.pm
index 1b96835..eb60177 100644 (file)
@@ -3,13 +3,14 @@ package DBIx::Class::CDBICompat::Iterator;
 use strict;
 use warnings;
 
+
 =head1 NAME
 
-DBIx::Class::CDBICompat::Iterator
+DBIx::Class::CDBICompat::Iterator - Emulates the extra behaviors of the Class::DBI search iterator.
 
 =head1 SYNOPSIS
 
-See DBIx::Class::CDBICompat for directions for use.
+See DBIx::Class::CDBICompat for usage directions.
 
 =head1 DESCRIPTION
 
@@ -24,7 +25,7 @@ The CDBI iterator returns true if there were any results, false otherwise.  The
 
 sub _init_result_source_instance {
   my $class = shift;
-  
+
   my $table = $class->next::method(@_);
   $table->resultset_class("DBIx::Class::CDBICompat::Iterator::ResultSet");
 
@@ -41,7 +42,23 @@ use warnings;
 use base qw(DBIx::Class::ResultSet);
 
 sub _bool {
-  return $_[0]->count;
+    # Performance hack so internal checks whether the result set
+    # exists won't do a SQL COUNT.
+    return 1 if caller =~ /^DBIx::Class::/;
+
+    return $_[0]->count;
+}
+
+sub _construct_results {
+  my $self = shift;
+
+  my $rows = $self->next::method(@_);
+
+  if (my $f = $self->_resolved_attrs->{record_filter}) {
+    $_ = $f->($_) for @$rows;
+  }
+
+  return $rows;
 }
 
 1;