| 1 | package DBIx::Class::CDBICompat::Iterator; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | |||||||||||
| 7 | =head1 NAME | ||||||||||
| 8 | |||||||||||
| 9 | DBIx::Class::CDBICompat::Iterator - Emulates the extra behaviors of the Class::DBI search iterator. | ||||||||||
| 10 | |||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||
| 12 | |||||||||||
| 13 | See DBIx::Class::CDBICompat for usage directions. | ||||||||||
| 14 | |||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||
| 16 | |||||||||||
| 17 | Emulates the extra behaviors of the Class::DBI search iterator. | ||||||||||
| 18 | |||||||||||
| 19 | =head2 Differences from DBIx::Class result set | ||||||||||
| 20 | |||||||||||
| 21 | The CDBI iterator returns true if there were any results, false otherwise. The DBIC result set always returns true. | ||||||||||
| 22 | |||||||||||
| 23 | =cut | ||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | sub _init_result_source_instance { | ||||||||||
| 27 | 0 | ▶ | my $class = shift; | ||||||||
|
Subroutine
_init_result_source_instance: not called CC=1 SCAR=6.9
| |||||||||||
| 28 | |||||||||||
| 29 | 0 | my $table = $class->next::method(@_); | |||||||||
| 30 | 0 | $table->resultset_class("DBIx::Class::CDBICompat::Iterator::ResultSet"); | |||||||||
| 31 | |||||||||||
| 32 | 0 | return $table; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | |||||||||||
| 36 | |||||||||||
| 37 | package DBIx::Class::CDBICompat::Iterator::ResultSet; | ||||||||||
| 38 | |||||||||||
| 39 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 40 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 41 | |||||||||||
| 42 | 1 | ▶ | use base qw(DBIx::Class::ResultSet); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 43 | |||||||||||
| 44 | sub _bool { | ||||||||||
| 45 | # Performance hack so internal checks whether the result set | ||||||||||
| 46 | # exists won't do a SQL COUNT. | ||||||||||
| 47 | 0 | ▶ | return 1 if caller =~ /^DBIx::Class::/; | ||||||||
|
Subroutine
_bool: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||
| 48 | |||||||||||
| 49 | 0 | return $_[0]->count; | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | sub _construct_results { | ||||||||||
| 53 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_construct_results: not called CC=3 SCAR=24.8
| |||||||||||
| 54 | |||||||||||
| 55 | 0 | my $rows = $self->next::method(@_); | |||||||||
| 56 | |||||||||||
| 57 | 0 | ▶ | if (my $f = $self->_resolved_attrs->{record_filter}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | 0 | $_ = $f->($_) for @$rows; | |||||||||
| 59 | } | ||||||||||
| 60 | |||||||||||
| 61 | 0 | return $rows; | |||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 1 | 1; | |||||||||