1 package Moose::Meta::Attribute::Native::Trait::Bool;
4 with 'Moose::Meta::Attribute::Native::Trait';
6 sub _default_is { 'rw' }
7 sub _helper_type { 'Bool' }
28 flip_switch => 'toggle',
33 my $room = Room->new();
34 $room->illuminate; # same as $room->is_lit(1);
35 $room->darken; # same as $room->is_lit(0);
36 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
37 return $room->is_dark; # same as !$room->is_lit
41 This trait provides native delegation methods for boolean values. A boolean is
42 a scalar which can be C<1>, C<0>, C<"">, or C<undef>.
46 If you don't provide an C<isa> value for your attribute, it will default to
49 =head1 PROVIDED METHODS
51 None of these methods accept arguments.
57 Sets the value to C<1> and returns C<1>.
61 Set the value to C<0> and returns C<0>.
65 Toggles the value. If it's true, set to false, and vice versa.
67 Returns the new value.
71 Equivalent of 'not C<$value>'.
77 See L<Moose/BUGS> for details on reporting bugs.