| 1 | 27 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||
| 3 | package Ekorn::Pipeline::Stage; | ||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||
| 5 | 27 | ▶ | use parent 'Ekorn::Pipeline::Element'; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||
| 7 | 27 | ▶ | use experimental qw(builtin); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 8 | 27 | ▶ | use builtin qw(blessed); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 9 | 27 | ▶ | use overload qw(); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 10 | 27 | ▶ | use Ref::Util qw(is_coderef); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 11 | 27 | ▶ | use Ekorn::Pipeline::Errors qw(croakf); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 12 | 27 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||
| 14 | # Croak at the line that called Ekorn::Pipeline. | ||||||||||||||||||||||||||||||||||
| 15 | 27 | our @CARP_NOT = @Ekorn::Pipeline::Errors::INTERNAL; | |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||
| 17 | # Return a stage of the code given, which is kept as it is, never | ||||||||||||||||||||||||||||||||||
| 18 | # blessed: a code reference, or an object called as one that isn't | ||||||||||||||||||||||||||||||||||
| 19 | # itself one of Ekorn's types. An object's code is found once, here, as | ||||||||||||||||||||||||||||||||||
| 20 | # a run takes a step that's a code reference. | ||||||||||||||||||||||||||||||||||
| 21 | 915 | ▶ | sub new ($class, $code) { | ||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 22 | 915 | ▶ | my $callable | ||||||||||||||||||||||||||||||||
|
Condition83%5/6
Ref::Util::XS::is_coderef($code) || builtin::blessed($code) && overload::Method($code, '&{}')
builtin::blessed($code) and overload::Method($code, "&{}")
MC/DC66%2/3
Ref::Util::XS::is_coderef($code) || builtin::blessed($code) && overload::Method($code, '&{}')
Ref::Util::XS::is_coderef($code)
builtin::blessed($code)
overload::Method($code, "&{}")
Truth table75%3/4
A || B and C
A= Ref::Util::XS::is_coderef($code)B= builtin::blessed($code)C= overload::Method($code, "&{}")
| |||||||||||||||||||||||||||||||||||
| 23 | = is_coderef($code) || (blessed($code) && overload::Method($code, '&{}')); | ||||||||||||||||||||||||||||||||||
| 24 | 915 | ▶ | croakf 'Expected a code reference' unless $callable; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 25 | 913 | ▶ | croakf q(Expected a code reference, not one of Ekorn's types) | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 26 | if $code isa 'Ekorn::Pipeline::Element'; | ||||||||||||||||||||||||||||||||||
| 27 | 912 | ▶ | return bless {call => is_coderef($code) ? $code : \&$code, code => $code}, | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 28 | $class; | ||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||
| 32 | # Return the code the stage was made of. | ||||||||||||||||||||||||||||||||||
| 33 | 5 | ▶ | sub code ($self) { | ||||||||||||||||||||||||||||||||
|
Subroutine
code: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 34 | 5 | return $self->{code}; | |||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||
| 38 | # Return the stage's step for a new run: its code, as a code reference. | ||||||||||||||||||||||||||||||||||
| 39 | 566 | ▶ | sub EKORN_STAGE ($self) { | ||||||||||||||||||||||||||||||||
|
Subroutine
EKORN_STAGE: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||
| 40 | 566 | return $self->{call}; | |||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||
| 43 | 27 | 1; | |||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||
| 45 | __END__ | ||||||||||||||||||||||||||||||||||