Data-Tubes

 view release on metacpan or  search on metacpan

lib/Data/Tubes.pod  view on Meta::CPAN

=back

The package name will be subject to some analysis that will make using
it a bit easier, by means of L<Data::Tubes::Util/resolve_module>.

You can optionally pass a hash reference with options as the last
parameter, with the following options:

=over

=item C<package>

the package where the loaded sub should be imported. Defaults to the
package calling the C<summon> function;

=item C<prefix>

the prefix to apply when needed. Defaults to C<Data::Tubes::Plugin>.
Note that you MUST NOT put the C<::>, it will be added automatically.

=back

=head2 B<< tube >>

   $tube = tube($factory_locator, @parameters); # OR
   $tube = tube(\@factory_locator, @parameters); # OR
   $tube = tube(\%opts, $factory_locator, @parameters); # OR
   $tube = tube(\%opts, \@factory_locator, @parameters);

this allows you to facilitate the creation of a tube, doing most of the
heavy-lifting automatically.

The first parameter can optionally be a I<hash reference> of options.
Currently, the only supported option is C<prefix>, which allows you to
set an alternative prefix with respect to what
C<Data::Tubes::Util/load_sub> would assume by default.

The following (or first, if C<%opts> is missing) parameter is used as a
I<locator> of a factory method to generate the real tube. It can be
either a string, or an array reference containing two elements, a
package name and a subroutine name inside that package. The function
L<Data::Tubes::Util/load_sub> is used to load the factory method
automatically, which means that the package name is subject to the same
rules described in L</summon> above.

After the factory function is loaded, it is called with the provided
C<@parameters> and the returned value... returned back.

Hence, this is a quick way to load some factory from a plugin and call
it in one, single call:

   # no additional parameters
   $files = tube('Source::iterate_files');

   # set some parameters for iterate_files
   $files = tube('Source::iterate_files', binmode => ':raw');

Most of the times, you are probably looking for L</pipeline> above,
as that will eventually call C<tube> automatically.

=head1 BUGS AND LIMITATIONS

Report bugs through GitHub (patches welcome) at
L<https://github.com/polettix/Data-Tubes>.

=head1 AUTHOR

Flavio Poletti <polettix@cpan.org>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2022 by Flavio Poletti <polettix@cpan.org>

This module is free software. You can redistribute it and/or modify it
under the terms of the Artistic License 2.0.

This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.

=cut



( run in 1.000 second using v1.01-cache-2.11-cpan-39bf76dae61 )