1 package Moose::Meta::Attribute::Native::Trait::Bool;
5 $VERSION = eval $VERSION;
6 our $AUTHORITY = 'cpan:STEVAN';
8 use Moose::Meta::Method::Accessor::Native::Bool::not;
9 use Moose::Meta::Method::Accessor::Native::Bool::set;
10 use Moose::Meta::Method::Accessor::Native::Bool::toggle;
11 use Moose::Meta::Method::Accessor::Native::Bool::unset;
13 with 'Moose::Meta::Attribute::Native::Trait';
15 sub _default_is { 'rw' }
16 sub _helper_type { 'Bool' }
26 Moose::Meta::Attribute::Native::Trait::Bool - Helper trait for Bool attributes
41 flip_switch => 'toggle',
46 my $room = Room->new();
47 $room->illuminate; # same as $room->is_lit(1);
48 $room->darken; # same as $room->is_lit(0);
49 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
50 return $room->is_dark; # same as !$room->is_lit
54 This provides a simple boolean attribute, which supports most of the
55 basic math operations.
57 =head1 PROVIDED METHODS
63 Sets the value to C<1>.
67 Set the value to C<0>.
71 Toggles the value. If it's true, set to false, and vice versa.
75 Equivalent of 'not C<$value>'.
89 See L<Moose/BUGS> for details on reporting bugs.
95 =head1 COPYRIGHT AND LICENSE
97 Copyright 2007-2009 by Infinity Interactive, Inc.
99 L<http://www.iinteractive.com>
101 This library is free software; you can redistribute it and/or modify
102 it under the same terms as Perl itself.