1 package Moose::AttributeHelpers::Trait::Bool;
3 use Moose::AttributeHelpers::MethodProvider::Bool;
6 $VERSION = eval $VERSION;
7 our $AUTHORITY = 'cpan:STEVAN';
9 with 'Moose::AttributeHelpers::Trait::Base';
11 sub _default_is { 'rw' }
12 sub _helper_type { 'Bool' }
15 # we don't use the method provider for this
16 # module since many of the names of the provied
17 # methods would conflict with keywords
20 has 'method_provider' => (
23 predicate => 'has_method_provider',
24 default => 'Moose::AttributeHelpers::MethodProvider::Bool'
29 # register the alias ...
30 package # hide me from search.cpan.org
31 Moose::Meta::Attribute::Custom::Trait::Bool;
32 sub register_implementation { 'Moose::AttributeHelpers::Trait::Bool' }
40 Moose::AttributeHelpers::Bool
46 use Moose::AttributeHelpers;
56 flip_switch => 'toggle',
61 my $room = Room->new();
62 $room->illuminate; # same as $room->is_lit(1);
63 $room->darken; # same as $room->is_lit(0);
64 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
65 return $room->is_dark; # same as !$room->is_lit
69 This provides a simple boolean attribute, which supports most of the
70 basic math operations.
78 =item B<method_constructors>
80 =item B<has_method_provider>
82 =item B<method_provider>
86 =head1 PROVIDED METHODS
88 It is important to note that all those methods do in place
89 modification of the value stored in the attribute.
95 Sets the value to C<1>.
99 Set the value to C<0>.
103 Toggle the value. If it's true, set to false, and vice versa.
107 Equivalent of 'not C<$value>'.
113 All complex software has bugs lurking in it, and this module is no
114 exception. If you find a bug please either email me, or add the bug
121 =head1 COPYRIGHT AND LICENSE
123 Copyright 2007-2009 by Infinity Interactive, Inc.
125 L<http://www.iinteractive.com>
127 This library is free software; you can redistribute it and/or modify
128 it under the same terms as Perl itself.