1 package Moose::Meta::Attribute::Native::Trait::Bool;
3 use Moose::Meta::Attribute::Native::MethodProvider::Bool;
6 $VERSION = eval $VERSION;
7 our $AUTHORITY = 'cpan:STEVAN';
9 with 'Moose::Meta::Attribute::Native::Trait';
11 sub _default_is { 'rw' }
12 sub _helper_type { 'Bool' }
14 has 'method_provider' => (
17 predicate => 'has_method_provider',
18 default => 'Moose::Meta::Attribute::Native::MethodProvider::Bool'
29 Moose::Meta::Attribute::Native::Trait::Bool - Helper trait for Bool attributes
44 flip_switch => 'toggle',
49 my $room = Room->new();
50 $room->illuminate; # same as $room->is_lit(1);
51 $room->darken; # same as $room->is_lit(0);
52 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
53 return $room->is_dark; # same as !$room->is_lit
57 This provides a simple boolean attribute, which supports most of the
58 basic math operations.
60 =head1 PROVIDED METHODS
62 These methods are implemented in
63 L<Moose::Meta::Attribute::Native::MethodProvider::Bool>. It is important to
64 note that all those methods do in place modification of the value stored in
71 Sets the value to C<1>.
75 Set the value to C<0>.
79 Toggles the value. If it's true, set to false, and vice versa.
83 Equivalent of 'not C<$value>'.
93 =item B<has_method_provider>
95 =item B<method_provider>
101 See L<Moose/BUGS> for details on reporting bugs.
107 =head1 COPYRIGHT AND LICENSE
109 Copyright 2007-2009 by Infinity Interactive, Inc.
111 L<http://www.iinteractive.com>
113 This library is free software; you can redistribute it and/or modify
114 it under the same terms as Perl itself.