MooseX...t::Bool(3pm)

πŸ“¦
version 0.25 Β· 6 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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:

  • meta
  • helper_type
  • method_constructors
  • has_method_provider
  • method_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 to 1. That's it. On. Lit. Slay. ⭐
  • unset β€” sets the value to 0. 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 of not $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. πŸ‘‘


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