MouseX...::Bool(3pm)

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

πŸ’– NAME πŸ’–

MouseX::NativeTraits::Bool β€” it's the helper trait for Bool attributes, bestie. That's the whole job and she does it flawlessly. ✨

This one lives in the MouseX...::Bool(3pm) corner of the User Contributed Perl Documentation, and yes she's iconic for it. πŸ‘‘


🌸 SYNOPSIS 🌸

  package Room;
  use Mouse;

  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

okay but the way you can just hand out cute little nicknames for the same boolean and it all still works?? main character energy fr fr πŸ¦‹


✨ DESCRIPTION ✨

So basically πŸ’… this gives you a simple boolean attribute, and it supports most of the basic math operations. That's it, that's the vibe. A little true/false that can do math. She's lowkey overqualified.


πŸŽ€ PROVIDED METHODS πŸŽ€

These methods are implemented over in MouseX::NativeTraits::MethodProvider::Bool. Important bestie, don't skip this: every single one of these methods does an in-place modification of the value stored in the attribute. Like, she's not making a copy for you, she's editing the original. no cap. πŸ™ˆ

  • set β€” sets the value to true. slay.
  • unset β€” sets the value to false. okay periodt.
  • toggle β€” flips the value. if it's true it goes false, and vice versa. it's giving light switch. πŸ’‘
  • not β€” the equivalent of not $value. literally just that. πŸ’œ

πŸ¦‹ METHODS πŸ¦‹

  • meta
  • method_provider_class
  • helper_type

🌈 SEE ALSO 🌈

  • MouseX::NativeTraits.

that's the whole page, you ate it, go build something cute 🫢

signed off with love β€” perl v5.34.0, dated 2022-06-16 β­πŸŽ€βœ¨

πŸ“¦ where this page comes from