| 1 | 31 | ▶ | use v5.36; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | |||||||||||
| 3 | package Ekorn::Pipeline::Gather; | ||||||||||
| 4 | |||||||||||
| 5 | 31 | ▶ | use parent 'Ekorn::Pipeline::Element'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 31 | ▶ | use Exporter qw(import); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 31 | ▶ | use Ref::Util qw(is_coderef); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 31 | ▶ | use Ekorn::Pipeline::Errors qw(croakf); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 31 | ▶ | use namespace::clean -except => 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 31 | our $VERSION = 'v0.4.0'; | |||||||||
| 15 | |||||||||||
| 16 | 31 | our @EXPORT = qw(gather); ## no critic (Modules::ProhibitAutomaticExportation) | |||||||||
| 17 | |||||||||||
| 18 | # Croak at the line that called Ekorn::Pipeline. | ||||||||||
| 19 | 31 | our @CARP_NOT = @Ekorn::Pipeline::Errors::INTERNAL; | |||||||||
| 20 | |||||||||||
| 21 | # Return a stage a pipeline makes afresh for each run, by calling the | ||||||||||
| 22 | # block given, which returns the stage's step, and optionally its flush | ||||||||||
| 23 | # and its end. | ||||||||||
| 24 | 386 | ▶ | sub gather : prototype(&) ($block) { | ||||||||
|
Subroutine
gather: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 25 | 386 | return __PACKAGE__->new($block); | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | # Return a gather of the block given. Called, it calls the block, as | ||||||||||
| 29 | # the core does at the start of each run. | ||||||||||
| 30 | 386 | ▶ | sub new ($class, $block) { | ||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 31 | 386 | ▶ | croakf 'Expected a code reference' unless is_coderef($block); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 384 | ▶ | return bless {call => sub { $block->() }}, $class; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | # Return what the block returns for a new run: the step, or a pipeline | ||||||||||
| 36 | # of steps, and optionally a flush and an end. | ||||||||||
| 37 | 1556 | ▶ | sub EKORN_STAGE ($self) { | ||||||||
|
Subroutine
EKORN_STAGE: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 38 | 1556 | return $self->{call}->(); | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 31 | 1; | |||||||||
| 42 | __END__ | ||||||||||