Data::...neFlag(3pm)

πŸ“¦
version 0.11 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– NAME πŸ’–

okay so bestie, <pink>Data::Stream::Bulk::DoneFlag</pink> β€” this is the role that implements the is_done method in terms of a flag. that's the whole vibe. it lives in the perl man pages, the user contributed perl documentation section, and the page header calls it <cyan>Data::...neFlag(3pm)</cyan> because man page headers truncate like that, no cap πŸŽ€


✨ VERSION ✨

version 0.11 β€” that's the one, that's the version, periodt πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

okay here's the whole thing in action, look at her go:

package Data::Stream::Bulk::Blah;
use Moose;

with qw(Data::Stream::Bulk::DoneFlag);

sub get_more {
    if ( my @more = more() ) {
        return \@more;
    } else {
        return;
    }
}

like. the with line pulls in the role, and then get_more does its little thing. iconic behaviour honestly 🌸


🌈 DESCRIPTION 🌈

so this role implements the <purple>Data::Stream::Bulk</purple> core API, and it does it in terms of exactly one method: get_more. one method!! main character energy fr fr πŸ‘‘

and as a lil convenience (a treat, a gift, a lil snack πŸ“), it calls finished when the stream is exhausted, so your cleanup can actually happen. it's giving considerate. it's giving thoughtful. we love her.

classes like Data::Stream::Bulk::DBI and Data::Stream::Bulk::Callback use this. iykyk πŸ’œ


πŸ’… METHODS πŸ’…

  • is_done β€” returns the state of the iterator. that's it, that's the whole job. state check, slay ✨
  • next β€” as long as the iterator is not yet done, this calls get_more. lowkey the whole engine of the thing.

and listen: if get_more returned a false value instead of an array reference, then done gets set, finished gets called, and this next does nothing on subsequent calls. nothing. nada. it's retired. it said "i'm done here" and meant it 😭

  • finished β€” a noop by default, bestie. it just sits there being nothing. but you can override it if you so desire, and honestly if you're doing cleanup you probably do desire 🫢

πŸŽ€ REQUIRED_METHODS πŸŽ€

  • get_more β€” returns the next block of data as an array ref, or a false value if there are no items left. that's the deal. that's the contract. array ref or false, no in-between πŸ’€

πŸ‘‘ AUTHOR πŸ‘‘

Yuval Kogman <nothingmuch@woobling.org> β€” the legend, the author, the one who did all this πŸ’–


This software is copyright (c) 2012 by Yuval Kogman.

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


and that's the whole page, bestie!! 🧚 it was documented as <purple>Data::...neFlag(3pm)</purple> by the user contributed perl documentation crew, running on perl v5.32.0, dated 2021-01-01. love that for us, mwah πŸ’œβ­

πŸ“¦ where this page comes from