| 1 | 28 | ▶ | use v5.36; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 2 | |||||||||||||
| 3 | package DBIx::Squirrel::Results; | ||||||||||||
| 4 | |||||||||||||
| 5 | 28 | ▶ | use DBIx::Squirrel::Errors qw(at_caller croakf); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 28 | ▶ | use DBIx::Squirrel::Iterator qw(); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 28 | ▶ | use DBIx::Squirrel::Result qw(); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 28 | ▶ | use namespace::clean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | 28 | our @ISA = ('DBIx::Squirrel::Iterator'); | |||||||||||
| 13 | |||||||||||||
| 14 | # Croak at the line that called DBIx::Squirrel. | ||||||||||||
| 15 | 28 | our @CARP_NOT = @DBIx::Squirrel::Errors::INTERNAL; | |||||||||||
| 16 | |||||||||||||
| 17 | # Fetch rows as arrays, whatever ekorn_slice says, as their classes find | ||||||||||||
| 18 | # columns by position. | ||||||||||||
| 19 | 46 | ▶ | sub _slice ($self) { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||
|
Subroutine
_slice: called CC=1 SCAR=0.0
| |||||||||||||
| 20 | 46 | return []; | |||||||||||
| 21 | } | ||||||||||||
| 22 | |||||||||||||
| 23 | # Return what blesses each row into the class for the statement's | ||||||||||||
| 24 | # columns, found from their names as a run starts. That's before a row | ||||||||||||
| 25 | # is fetched: once the last row is, a driver such as DBD::mysql has let | ||||||||||||
| 26 | # the names go. The run keeps the class, so a pipeline reading the rows | ||||||||||||
| 27 | # after the result set is let go still gets objects. | ||||||||||||
| 28 | 45 | ▶ | sub _row_maker ($self, $sth) { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) | ||||||||||
|
Subroutine
_row_maker: called CC=2 SCAR=6.9
| |||||||||||||
| 29 | 45 | ▶ | my $names = at_caller { $sth->{NUM_OF_FIELDS} ? $sth->{NAME_lc} : undef }; | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||
| 30 | 45 | ▶ | return undef unless $names; ## no critic (Subroutines::ProhibitExplicitReturnUndef) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 31 | 44 | my $class = _base_class($self)->class_for($names); | |||||||||||
| 32 | # Without a signature, as it's called for each row, and a signature | ||||||||||||
| 33 | # costs about 20 ns a call (roadmap 2026-0028). | ||||||||||||
| 34 | 43 | ▶ | return sub { bless $_[0], $class }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 35 | } | ||||||||||||
| 36 | |||||||||||||
| 37 | # Return the base class of the rows' class: the ekorn_result_class | ||||||||||||
| 38 | # attribute, or DBIx::Squirrel::Result. | ||||||||||||
| 39 | 44 | ▶ | sub _base_class ($self) { | ||||||||||
|
Subroutine
_base_class: called CC=3 SCAR=11.0
| |||||||||||||
| 40 | my $base = $self->sth->{private_ekorn}{Options}{ekorn_result_class} | ||||||||||||
| 41 | 44 | ▶ | // 'DBIx::Squirrel::Result'; | ||||||||||
|
Condition100%2/2
$self->sth->{"private_ekorn"}{"Options"}{"ekorn_result_class"} // "DBIx::Squirrel::Result"
MC/DC100%1/1
$self->sth->{"private_ekorn"}{"Options"}{"ekorn_result_class"} // "DBIx::Squirrel::Result"
$self->sth->{"private_ekorn"}{"Options"}{"ekorn_result_class"}
Truth table100%2/2
A
A= $self->sth->{"private_ekorn"}{"Options"}{"ekorn_result_class"}
| |||||||||||||
| 42 | 44 | ▶ | croakf 'Expected ekorn_result_class to be a subclass of %s (%s)', | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 43 | 'DBIx::Squirrel::Result', $base | ||||||||||||
| 44 | unless $base->isa('DBIx::Squirrel::Result'); | ||||||||||||
| 45 | 43 | return $base; | |||||||||||
| 46 | } | ||||||||||||
| 47 | |||||||||||||
| 48 | 28 | 1; | |||||||||||
| 49 | __END__ | ||||||||||||