bump version to 1.15
[gitmo/Moose.git] / lib / Moose / Meta / Attribute / Native / Trait / Bool.pm
CommitLineData
c466e58f 1package Moose::Meta::Attribute::Native::Trait::Bool;
e3c07b19 2use Moose::Role;
e3c07b19 3
efa728b4 4our $VERSION = '1.15';
e3c07b19 5$VERSION = eval $VERSION;
6our $AUTHORITY = 'cpan:STEVAN';
7
664e417b 8use Moose::Meta::Method::Accessor::Native::Bool::not;
9use Moose::Meta::Method::Accessor::Native::Bool::set;
10use Moose::Meta::Method::Accessor::Native::Bool::toggle;
11use Moose::Meta::Method::Accessor::Native::Bool::unset;
12
c466e58f 13with 'Moose::Meta::Attribute::Native::Trait';
e3c07b19 14
55a9d564 15sub _default_is { 'rw' }
2e069f5a 16sub _helper_type { 'Bool' }
2edb73d9 17
e3c07b19 18no Moose::Role;
19
e3c07b19 201;
21
22=pod
23
24=head1 NAME
25
2420461c 26Moose::Meta::Attribute::Native::Trait::Bool - Helper trait for Bool attributes
e3c07b19 27
28=head1 SYNOPSIS
29
30 package Room;
31 use Moose;
e3c07b19 32
33 has 'is_lit' => (
9610c1d2 34 traits => ['Bool'],
e3c07b19 35 is => 'rw',
36 isa => 'Bool',
2edb73d9 37 default => 0,
5f3663b2 38 handles => {
39 illuminate => 'set',
40 darken => 'unset',
41 flip_switch => 'toggle',
42 is_dark => 'not',
9610c1d2 43 },
e3c07b19 44 );
45
46 my $room = Room->new();
47 $room->illuminate; # same as $room->is_lit(1);
48 $room->darken; # same as $room->is_lit(0);
49 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
50 return $room->is_dark; # same as !$room->is_lit
51
52=head1 DESCRIPTION
53
54This provides a simple boolean attribute, which supports most of the
55basic math operations.
56
e3c07b19 57=head1 PROVIDED METHODS
58
e3c07b19 59=over 4
60
eb465b32 61=item B<set>
e3c07b19 62
63Sets the value to C<1>.
64
eb465b32 65=item B<unset>
e3c07b19 66
67Set the value to C<0>.
68
eb465b32 69=item B<toggle>
e3c07b19 70
157e0475 71Toggles the value. If it's true, set to false, and vice versa.
e3c07b19 72
eb465b32 73=item B<not>
e3c07b19 74
75Equivalent of 'not C<$value>'.
76
77=back
78
55a9d564 79=head1 METHODS
80
81=over 4
82
83=item B<meta>
84
55a9d564 85=back
86
e3c07b19 87=head1 BUGS
88
d4048ef3 89See L<Moose/BUGS> for details on reporting bugs.
e3c07b19 90
91=head1 AUTHOR
92
93Jason May
94
95=head1 COPYRIGHT AND LICENSE
96
97Copyright 2007-2009 by Infinity Interactive, Inc.
98
99L<http://www.iinteractive.com>
100
101This library is free software; you can redistribute it and/or modify
102it under the same terms as Perl itself.
103
104=cut