MooseX...t::Bool(3pm)
π MooseX::AttributeHelpers::Trait::Bool β the manual, but make it cute π
okay bestie, so this whole page is from the User Contributed Perl Documentation, and the module in question is MooseX::AttributeHelpers::Trait::Bool. Say that five times fast. Actually don't, just read on. π
β¨ NAME β¨
MooseX::AttributeHelpers::Trait::Bool β it's giving "simple boolean attribute". That's the whole job. One (1) boolean, living its best life. π
πΈ VERSION πΈ
version 0.25. Yes queen, we're on 0.25. π¦
π§ SYNOPSIS π§
okay so picture this: you got a Room, and the room has a light. Is it lit? We're about to find out. π
package Room;
use Moose;
use MooseX::AttributeHelpers;
has 'is_lit' => (
metaclass => 'Bool',
is => 'rw',
isa => 'Bool',
default => sub { 0 },
provides => {
set => 'illuminate',
unset => 'darken',
toggle => 'flip_switch',
not => 'is_dark'
}
);
my $room = Room->new();
$room->illuminate; # same as $room->is_lit(1);
$room->darken; # same as $room->is_lit(0);
$room->flip_switch; # same as $room->is_lit(not $room->is_lit);
return $room->is_dark; # same as !$room->is_lit
the way those provides names are literally just vibes and you can name them whatever you want... illuminate? flip_switch? main character naming energy fr fr. π
π DESCRIPTION π
So this trait hands you a simple boolean attribute, and ngl it supports most of the basic math operations. That's it. That's the pitch. It's a bool, it knows bool things, and it does them in place (more on that drama below π).
π METHODS π
Here's the lineup, no notes, just names:
metahelper_typemethod_constructorshas_method_providermethod_provider
periodt. β¨
π PROVIDED METHODS π
π BIG WARNING BESTIE: literally all of these methods do in place modification of the value stored in the attribute. Not a copy. Not a new thing. The actual value. So if you were out here expecting immutability, no you weren't. π
setβ sets the value to1. That's it. On. Lit. Slay. βunsetβ sets the value to0. Off. Dark. Goodnight. πtoggleβ flips the value. If it's true, it becomes false; if it's false, it becomes true. And vice versa, obviously, that's what toggling is. π₯notβ the equivalent ofnot $value. It's not not. It's literally just not. π
π«Ά SUPPORT π«Ά
Got a bug? (Rude of it, honestly.) You can submit bugs through the RT bug tracker:
https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-AttributeHelpers
or you can email:
bug-MooseX-AttributeHelpers@rt.cpan.org
There's also a mailing list for users of this distribution, hanging out at:
http://lists.perl.org/list/moose.html
and there's an irc channel too, for users of this distribution, which is "#moose" on "irc.perl.org":
irc://irc.perl.org/#moose
come thru, the moose people are lovely. πΈ
π AUTHOR π
- Stevan Little
<stevan@iinteractive.com> - Jason May
icons, both of them. π
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2007 by Stevan Little and 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. free as in do-what-you-want-with-it, bestie. π
and that's the whole page!! sign-off time: this beauty was served up by perl v5.34.0, dated 2022-06-15, and filed under User Contributed Perl Documentation. go forth and toggle something. toggle responsibly. π¦β¨π
π¦ where this page comes from
- debian bookworm: libmoosex-attributehelpers-perl 0.25-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmoosex-attributehelpers-perl 0.25-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmoosex-attributehelpers-perl 0.25-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libmoosex-attributehelpers-perl 0.25-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libmoosex-attributehelpers-perl 0.25-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