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