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 # NOTE: we don't use the method provider for this module since many of
15 # the names of the provided methods would conflict with keywords - SL
17 has 'method_provider' => (
20 predicate => 'has_method_provider',
21 default => 'Moose::Meta::Attribute::Native::MethodProvider::Bool'
32 Moose::Meta::Attribute::Native::Trait::Bool
47 flip_switch => 'toggle',
52 my $room = Room->new();
53 $room->illuminate; # same as $room->is_lit(1);
54 $room->darken; # same as $room->is_lit(0);
55 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
56 return $room->is_dark; # same as !$room->is_lit
60 This provides a simple boolean attribute, which supports most of the
61 basic math operations.
63 =head1 PROVIDED METHODS
65 These methods are implemented in
66 L<Moose::Meta::Attribute::Native::MethodProvider::Bool>. It is important to
67 note that all those methods do in place modification of the value stored in
74 Sets the value to C<1>.
78 Set the value to C<0>.
82 Toggle the value. If it's true, set to false, and vice versa.
86 Equivalent of 'not C<$value>'.
96 =item B<method_constructors>
98 =item B<has_method_provider>
100 =item B<method_provider>
106 All complex software has bugs lurking in it, and this module is no
107 exception. If you find a bug please either email me, or add the bug
114 =head1 COPYRIGHT AND LICENSE
116 Copyright 2007-2009 by Infinity Interactive, Inc.
118 L<http://www.iinteractive.com>
120 This library is free software; you can redistribute it and/or modify
121 it under the same terms as Perl itself.