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