1 package Moose::Meta::Attribute::Native::Trait::Bool;
4 our $AUTHORITY = 'cpan:STEVAN';
6 with 'Moose::Meta::Attribute::Native::Trait';
8 sub _default_is { 'rw' }
9 sub _helper_type { 'Bool' }
30 flip_switch => 'toggle',
35 my $room = Room->new();
36 $room->illuminate; # same as $room->is_lit(1);
37 $room->darken; # same as $room->is_lit(0);
38 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
39 return $room->is_dark; # same as !$room->is_lit
43 This trait provides native delegation methods for boolean values. A boolean is
44 a scalar which can be C<1>, C<0>, C<"">, or C<undef>.
48 If you don't provide an C<isa> value for your attribute, it will default to
51 =head1 PROVIDED METHODS
53 None of these methods accept arguments.
59 Sets the value to C<1> and returns C<1>.
63 Set the value to C<0> and returns C<0>.
67 Toggles the value. If it's true, set to false, and vice versa.
69 Returns the new value.
73 Equivalent of 'not C<$value>'.
79 See L<Moose/BUGS> for details on reporting bugs.