MooseX...enBuilt(3pm)
π NAME π
MooseX::Storage::Engine::Trait::OnlyWhenBuilt β bestie, it's an engine trait that straight up bypasses serialization for stuff that hasn't been built yet β¨
πΈ VERSION πΈ
version 0.53 β yes she's got a number, and yes it's iconic π
π¦ SYNOPSIS π¦
okay so here's the vibe:
{ package Point;
use Moose;
use MooseX::Storage;
with Storage( traits => [qw|OnlyWhenBuilt|] );
has 'x' => (is => 'rw', lazy_build => 1 );
has 'y' => (is => 'rw', predicate => '_has_y' );
has 'z' => (is => 'rw', builder => '_build_z' );
sub _build_x { 3 }
sub _build_y { expensive_computation() }
sub _build_z { 3 }
}
my $p = Point->new( 'x' => 4 );
# the result of ->pack will contain:
# { x => 4, z => 3 }
$p->pack;
like, look at her go π
π DESCRIPTION π
sooooo sometimes you have an attribute and you're like... bestie, if nobody's built you yet, you do NOT need to be in the serialization. and that's literally the whole point of this trait π
if you invoke Storage() the way it's shown up in the SYNOPSIS, then only the attributes that have actually been built β as in, where the predicate returns 'true' β get serialized. which means no surprise expensive computations jumping out at you π this avoids any potentially expensive computations, fr fr.
this trait gets applied to an instance of MooseX::Storage::Engine. and if you're looking for the user-visible version that got shown off in the SYNOPSIS, that's MooseX::Storage::Traits::OnlyWhenBuilt π«Ά
π SUPPORT π
bugs? yeah, submit those through the RT bug tracker: <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-Storage> β or, if you prefer email energy, bug-MooseX-Storage@rt.cpan.org <mailto:bug-MooseX-Storage@rt.cpan.org> π¬
there's also a mailing list for people using this distribution, right here: <http://lists.perl.org/list/moose.html> π§
annnd there's an irc channel too, for users of this distribution, at #moose on irc.perl.org <irc://irc.perl.org/#moose> π¬ come hang, no cap.
β¨ AUTHORS β¨
- Chris Prather <chris.prather@iinteractive.com>
- Stevan Little <stevan.little@iinteractive.com>
- ΧΧΧΧ Χ§ΧΧ'ΧΧ (Yuval Kogman) <nothingmuch@woobling.org>
the legends themselves, we stan π«Ά
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2007 by Infinity Interactive, Inc.
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!! this one came out with perl v5.36.0 on 2022-10-16, and honestly?? she ate. mwah πβ¨π
π¦ where this page comes from
- ubuntu noble: libmoosex-storage-perl 0.53-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmoosex-storage-perl 0.53-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmoosex-storage-perl 0.53-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms