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 helper_type { 'Bool' }
13 sub _default_is { 'rw' }
16 # we don't use the method provider for this
17 # module since many of the names of the provied
18 # methods would conflict with keywords
21 has 'method_provider' => (
24 predicate => 'has_method_provider',
25 default => 'Moose::AttributeHelpers::MethodProvider::Bool'
30 # register the alias ...
31 package # hide me from search.cpan.org
32 Moose::Meta::Attribute::Custom::Trait::Bool;
33 sub register_implementation { 'Moose::AttributeHelpers::Trait::Bool' }
41 Moose::AttributeHelpers::Bool
47 use Moose::AttributeHelpers;
57 flip_switch => 'toggle',
62 my $room = Room->new();
63 $room->illuminate; # same as $room->is_lit(1);
64 $room->darken; # same as $room->is_lit(0);
65 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
66 return $room->is_dark; # same as !$room->is_lit
70 This provides a simple boolean attribute, which supports most of the
71 basic math operations.
81 =item B<method_constructors>
83 =item B<has_method_provider>
85 =item B<method_provider>
89 =head1 PROVIDED METHODS
91 It is important to note that all those methods do in place
92 modification of the value stored in the attribute.
98 Sets the value to C<1>.
102 Set the value to C<0>.
106 Toggle the value. If it's true, set to false, and vice versa.
110 Equivalent of 'not C<$value>'.
116 All complex software has bugs lurking in it, and this module is no
117 exception. If you find a bug please either email me, or add the bug
124 =head1 COPYRIGHT AND LICENSE
126 Copyright 2007-2009 by Infinity Interactive, Inc.
128 L<http://www.iinteractive.com>
130 This library is free software; you can redistribute it and/or modify
131 it under the same terms as Perl itself.