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
38 use Moose::AttributeHelpers;
48 flip_switch => 'toggle',
53 my $room = Room->new();
54 $room->illuminate; # same as $room->is_lit(1);
55 $room->darken; # same as $room->is_lit(0);
56 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
57 return $room->is_dark; # same as !$room->is_lit
61 This provides a simple boolean attribute, which supports most of the
62 basic math operations.
70 =item B<method_constructors>
72 =item B<has_method_provider>
74 =item B<method_provider>
78 =head1 PROVIDED METHODS
80 It is important to note that all those methods do in place
81 modification of the value stored in the attribute.
87 Sets the value to C<1>.
91 Set the value to C<0>.
95 Toggle the value. If it's true, set to false, and vice versa.
99 Equivalent of 'not C<$value>'.
105 All complex software has bugs lurking in it, and this module is no
106 exception. If you find a bug please either email me, or add the bug
113 =head1 COPYRIGHT AND LICENSE
115 Copyright 2007-2009 by Infinity Interactive, Inc.
117 L<http://www.iinteractive.com>
119 This library is free software; you can redistribute it and/or modify
120 it under the same terms as Perl itself.