File Coverage

blib/lib/DBIx/Class/CDBICompat/Iterator.pm
Criterion Covered Total %
statement 18 29 62.0
branch 0 4 0.0
condition n/a
subroutine 6 9 66.6
pod n/a
total 24 42 57.1


line stmt bran cond sub pod time code
1             package DBIx::Class::CDBICompat::Iterator;
2              
3 2     2   2009 use strict;
  2         5  
  2         49  
4 2     2   8 use warnings;
  2         4  
  2         43  
5              
6 2     2   9 use base 'DBIx::Class';
  2         4  
  2         273  
7              
8             =head1 NAME
9              
10             DBIx::Class::CDBICompat::Iterator - Emulates the extra behaviors of the Class::DBI search iterator.
11              
12             =head1 SYNOPSIS
13              
14             See DBIx::Class::CDBICompat for usage directions.
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              
27             sub _init_result_source_instance {
28 0     0     my $class = shift;
29              
30 0           my $table = $class->next::method(@_);
31 0           $table->resultset_class("DBIx::Class::CDBICompat::Iterator::ResultSet");
32              
33 0           return $table;
34             }
35              
36             =head1 FURTHER QUESTIONS?
37              
38             Check the list of L.
39              
40             =head1 COPYRIGHT AND LICENSE
41              
42             This module is free software L
43             by the L. You can
44             redistribute it and/or modify it under the same terms as the
45             L.
46              
47             =cut
48              
49             package # hide
50             DBIx::Class::CDBICompat::Iterator::ResultSet;
51              
52 2     2   12 use strict;
  2         5  
  2         34  
53 2     2   8 use warnings;
  2         6  
  2         51  
54              
55 2     2   10 use base qw(DBIx::Class::ResultSet);
  2         3  
  2         374  
56              
57             sub _bool {
58             # Performance hack so internal checks whether the result set
59             # exists won't do a SQL COUNT.
60 0 0   0     return 1 if caller =~ /^DBIx::Class::/;
61              
62 0           return $_[0]->count;
63             }
64              
65             sub _construct_results {
66 0     0     my $self = shift;
67              
68 0           my $rows = $self->next::method(@_);
69              
70 0 0         if (my $f = $self->_resolved_attrs->{record_filter}) {
71 0           $_ = $f->($_) for @$rows;
72             }
73              
74 0           return $rows;
75             }
76              
77             1;