Start setting the 'c3' mro unambiguously everywhere
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / CDBICompat / Iterator.pm
CommitLineData
c0494fe1 1package DBIx::Class::CDBICompat::Iterator;
2
3use strict;
4use warnings;
5
195dabc7 6
d03c0706 7=head1 NAME
8
b24d86a1 9DBIx::Class::CDBICompat::Iterator - Emulates the extra behaviors of the Class::DBI search iterator.
d03c0706 10
11=head1 SYNOPSIS
12
48580715 13See DBIx::Class::CDBICompat for usage directions.
d03c0706 14
15=head1 DESCRIPTION
16
17Emulates the extra behaviors of the Class::DBI search iterator.
18
19=head2 Differences from DBIx::Class result set
20
21The CDBI iterator returns true if there were any results, false otherwise. The DBIC result set always returns true.
22
23=cut
24
25
c0494fe1 26sub _init_result_source_instance {
27 my $class = shift;
d4daee7b 28
c0494fe1 29 my $table = $class->next::method(@_);
30 $table->resultset_class("DBIx::Class::CDBICompat::Iterator::ResultSet");
31
32 return $table;
33}
34
a2bd3796 35=head1 FURTHER QUESTIONS?
c0494fe1 36
a2bd3796 37Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
c0494fe1 38
a2bd3796 39=head1 COPYRIGHT AND LICENSE
40
41This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
42by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
43redistribute it and/or modify it under the same terms as the
44L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
45
46=cut
47
48package # hide
49 DBIx::Class::CDBICompat::Iterator::ResultSet;
c0494fe1 50
51use strict;
52use warnings;
53
54use base qw(DBIx::Class::ResultSet);
55
56sub _bool {
195dabc7 57 # Performance hack so internal checks whether the result set
58 # exists won't do a SQL COUNT.
59 return 1 if caller =~ /^DBIx::Class::/;
60
61 return $_[0]->count;
c0494fe1 62}
63
6ad439d4 64sub _construct_results {
65 my $self = shift;
66
67 my $rows = $self->next::method(@_);
68
69 if (my $f = $self->_resolved_attrs->{record_filter}) {
70 $_ = $f->($_) for @$rows;
71 }
72
73 return $rows;
74}
75
c0494fe1 761;