blib/lib/DBIx/Squirrel/Context.pm

filter: Statementstmt 100% 33 / 33 Branchbran 100% 2 / 2 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 3 / 3 totaltotal 96.2% 51 / 53 CC 3 SCAR 4.1
CC
3
Cov
97%
statement_context
3.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.5
« blib/lib/DBIx/Squirrel/Results.pm ↑ Summary blib/lib/DBIx/Squirrel/Gather.pm »
1 32 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 package DBIx::Squirrel::Context;
4  
5 32 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 32 ▶use Ref::Util qw(is_plain_hashref);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 32 ▶use DBIx::Squirrel::Errors qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 32 ▶use Ekorn::Pipeline qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 32 ▶use Ekorn::Pipeline::Context qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 32 ▶use namespace::clean -except => 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 32 our $VERSION = 'v4.3.0';
15  
16 32 our @EXPORT_OK = qw(iterator kept_origin result_number result_original);
17  
18 # Croak at the line that called DBIx::Squirrel.
19 32 our @CARP_NOT = @DBIx::Squirrel::Errors::INTERNAL;
20  
21 # The iterator running the stages, set by the iterator while they run; a
22 # package variable, so the iterator's next can localise it itself,
23 # without a call for each row.
24 32 our $ITERATOR;
25  
26 # The iterator running the stage.
27 12 ▶sub iterator : prototype() () {
Subroutine iterator: called CC=1 SCAR=0.0
Pod documented
28 12 return $ITERATOR;
29 }
30  
31 # The number of the result being made, from 1: Ekorn's own sub, under our
32 # name, as every run counts its results (roadmap 2026-0032, D1), so a
33 # stage reading it pays for one call, not two. Ekorn's has an empty
34 # prototype from v0.3.12, as ours always had, so result_number + 1 adds
35 # one.
36 32 *result_number = \&Ekorn::Pipeline::Context::result_number;
37  
38 # The row the result is being made from, as it was fetched; undef for a
39 # result made from many rows, as a flush's or a batch's are, unless a
40 # stage that holds values back says which row it came from: Ekorn's own
41 # sub, under our name, as our statement source gives Ekorn the row as
42 # its original part, which Ekorn passes through chains (roadmap
43 # 2026-0046) and past stages that hold values back (roadmap 2026-0065).
44 # Outside a run reading a statement, it's the value the run's source
45 # gave (roadmap 2026-0032, D2).
46 32 *result_original = \&Ekorn::Pipeline::Context::result_original;
47  
48 # For a stage that holds values back, the origin of the value it's
49 # keeping: Ekorn's own sub, under our name, so the two :context tags
50 # stay the same (roadmap 2026-0065, D1).
51 32 *kept_origin = \&Ekorn::Pipeline::Context::kept_origin;
52  
53 # For DBIx::Squirrel's stages: the context of the run, if its source is a
54 # statement, with its columns and the row it gave last; otherwise undef.
55 51 ▶sub statement_context : prototype() () {
Subroutine statement_context: called CC=3 SCAR=11.1
Pod documented
56 51 my $run = Ekorn::Pipeline::run_context();
57 return is_plain_hashref($run)
58 51 ▶ && $run->{statement} isa 'DBIx::Squirrel::st'
Branch: 1 branch
BranchTrueFalseTotal
Ref::Util::XS::is_plain_hashref($run) && $run->{'statement'} isa 'DBIx::Squirrel::st' ? : 44 7 51
Condition66%2/3
Ref::Util::XS::is_plain_hashref($run) and $run->{"statement"} isa "DBIx::Squirrel::st"
!ll&&!rl&&r
7044
MC/DC50%1/2
Ref::Util::XS::is_plain_hashref($run) and $run->{"statement"} isa "DBIx::Squirrel::st"
Ref::Util::XS::is_plain_hashref($run) $run->{"statement"} isa "DBIx::Squirrel::st"
Truth table66%2/3
A and B
A= Ref::Util::XS::is_plain_hashref($run)B= $run->{"statement"} isa "DBIx::Squirrel::st"
ABresult
0X0
100
111
59 ? $run
60 : undef;
61 }
62  
63 # For DBIx::Squirrel's iterators: run code with the iterator given as the
64 # one running, and return what it returns.
65 412 ▶sub within ($iterator, $code) {
Subroutine within: called CC=1 SCAR=0.0
Pod documented
66 412 local $ITERATOR = $iterator;
67 412 return $code->();
68 }
69  
70 32 1;
71 __END__
« blib/lib/DBIx/Squirrel/Results.pm ↑ Summary blib/lib/DBIx/Squirrel/Gather.pm »