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