Moose::...it::Bool(3)
β¨ Moose::Meta::Attribute::Native::Trait::Bool β the helper trait for Bool attributes β¨
okay bestie, welcome to the Moose::...it::Bool(3) page (yes that's the shortened name, the full one is Moose::Meta::Attribute::Native::Trait::Bool and it's a whole mouthful, we don't gatekeep) π
π« VERSION
version 2.4000 β she's serving, she's current, she's iconic π
πΈ SYNOPSIS
okay so picture this: you want a boolean attribute but you also want cute little named methods for flipping it around. say less:
package Room;
use Moose;
has 'is_lit' => (
traits => ['Bool'],
is => 'rw',
isa => 'Bool',
default => 0,
handles => {
illuminate => 'set',
darken => 'unset',
flip_switch => 'toggle',
is_dark => 'not',
},
);
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
like. the way flip_switch is just right there doing the most. obsessed π
π¦ DESCRIPTION
This trait hands you native delegation methods for boolean values, no cap. And a boolean, for the record, is a scalar that can be 1, 0, "", or "undef". that's the whole vibe check. β
β DEFAULT TYPE
If you don't hand over an isa value for your attribute, it just defaults to Bool. she's lowkey self-sufficient like that π
π PROVIDED METHODS
Real talk: none of these methods accept arguments. not a single one. they take zero input and they deliver.
setβ sets the value to1and returns1. simple, clean, ate.unsetβ sets the value to0and returns0. the opposite queen.toggleβ toggles the value: if it's true, it sets it to false, and vice versa. and she returns the new value, because she's generous.notβ the equivalent ofnot $value. that's it, that's the whole thing. fr fr.
π BUGS
Want the tea on reporting bugs? See "BUGS" in Moose for all the details. go off, file that report π«Ά
π AUTHORS
these are the legends who made this happen, show some respect:
- Stevan Little
<stevan@cpan.org> - Dave Rolsky
<autarch@urth.org> - Jesse Luehrs
<doy@cpan.org> - Shawn M Moore
<sartak@cpan.org> - ΧΧΧΧ Χ§ΧΧ'ΧΧ (Yuval Kogman)
<nothingmuch@woobling.org> - Karen Etheridge
<ether@cpan.org> - Florian Ragwitz
<rafl@debian.org> - Hans Dieter Pearcey
<hdp@cpan.org> - Chris Prather
<chris@prather.org> - Matt S Trout
<mstrout@cpan.org>
π§ COPYRIGHT AND LICENSE
This software is copyright (c) 2006 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. yes bestie, free as in freedom, go wild.
π cute sign-off time: this lil page came from perlv5.42.0, dated2025-07-25, in the User Contributed Perl Documentation. that's a wrap, bestie β go flip some switches π₯π
π¦ where this page comes from
- fedora 43: perl-Moose 2.4000-4.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms