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
59 These methods are implemented in
60 L<Moose::Meta::Attribute::Native::MethodProvider::Bool>. It is important to
61 note that all those methods do in place modification of the value stored in
68 Sets the value to C<1>.
72 Set the value to C<0>.
76 Toggles the value. If it's true, set to false, and vice versa.
80 Equivalent of 'not C<$value>'.
90 =item B<has_method_provider>
92 =item B<method_provider>
98 See L<Moose/BUGS> for details on reporting bugs.
104 =head1 COPYRIGHT AND LICENSE
106 Copyright 2007-2009 by Infinity Interactive, Inc.
108 L<http://www.iinteractive.com>
110 This library is free software; you can redistribute it and/or modify
111 it under the same terms as Perl itself.