NAME

Ekorn::Pipeline::Pipes - pipe and tap methods, running an object through stages

SYNOPSIS

package My::Client;

use parent 'Ekorn::Pipeline::Pipes';

package main;

my $client = My::Client->new;

# What the stages make of the object
my @names = $client->pipe(sub { $_->users }, sub { $_->{name} });

# The object itself, after the stages have run for their side effects
$client->tap(sub { $_->log('started') })->run;

DESCRIPTION

A parent class giving its children two methods, pipe and tap, which run the object they're called on through a pipeline of stages, as Ekorn::Pipeline describes. The first stage is called with the object, in $_ and as its argument.

DBIx::Squirrel's database and statement handles have the same two methods, and are where they began.

METHODS

pipe

@results = $object->pipe(@stages);
$first   = $object->pipe(@stages);

Runs the invocant through a pipeline of @stages, and returns what comes out of the last one. In scalar context, it returns the first of them, or undef if there are none. With no stages, it returns the invocant.

tap

$object = $object->tap(@stages);

Runs the invocant through a pipeline of @stages for their side effects, and returns the invocant, whatever comes out of the stages, so a chain of method calls can carry on after it.

SEE ALSO

Ekorn::Pipeline, Ekorn::Pipeline::Stages::Taps

AUTHOR

Iain Campbell <cpanic@cpan.org>

LICENSE

Copyright (c) 2024-2026 by Iain Campbell.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.