bump version to 0.89_01
[gitmo/Moose.git] / lib / Moose / Meta / Attribute / Native / Trait / Bool.pm
1 package Moose::Meta::Attribute::Native::Trait::Bool;
2 use Moose::Role;
3 use Moose::Meta::Attribute::Native::MethodProvider::Bool;
4
5 our $VERSION = '0.89_01';
6 $VERSION = eval $VERSION;
7 our $AUTHORITY = 'cpan:STEVAN';
8
9 with 'Moose::Meta::Attribute::Native::Trait';
10
11 sub _default_is  { 'rw' }
12 sub _helper_type { 'Bool' }
13
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
16
17 has 'method_provider' => (
18     is        => 'ro',
19     isa       => 'ClassName',
20     predicate => 'has_method_provider',
21     default   => 'Moose::Meta::Attribute::Native::MethodProvider::Bool'
22 );
23
24 no Moose::Role;
25
26 1;
27
28 =pod
29
30 =head1 NAME
31
32 Moose::Meta::Attribute::Native::Trait::Bool
33
34 =head1 SYNOPSIS
35
36   package Room;
37   use Moose;
38
39   has 'is_lit' => (
40       traits    => ['Bool'],
41       is        => 'rw',
42       isa       => 'Bool',
43       default   => 0,
44       handles   => {
45           illuminate  => 'set',
46           darken      => 'unset',
47           flip_switch => 'toggle',
48           is_dark     => 'not',
49       },
50   );
51
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
57
58 =head1 DESCRIPTION
59
60 This provides a simple boolean attribute, which supports most of the
61 basic math operations.
62
63 =head1 PROVIDED METHODS
64
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
68 the attribute.
69
70 =over 4
71
72 =item B<set>
73
74 Sets the value to C<1>.
75
76 =item B<unset>
77
78 Set the value to C<0>.
79
80 =item B<toggle>
81
82 Toggles the value. If it's true, set to false, and vice versa.
83
84 =item B<not>
85
86 Equivalent of 'not C<$value>'.
87
88 =back
89
90 =head1 METHODS
91
92 =over 4
93
94 =item B<meta>
95
96 =item B<method_constructors>
97
98 =item B<has_method_provider>
99
100 =item B<method_provider>
101
102 =back
103
104 =head1 BUGS
105
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
108 to cpan-RT.
109
110 =head1 AUTHOR
111
112 Jason May
113
114 =head1 COPYRIGHT AND LICENSE
115
116 Copyright 2007-2009 by Infinity Interactive, Inc.
117
118 L<http://www.iinteractive.com>
119
120 This library is free software; you can redistribute it and/or modify
121 it under the same terms as Perl itself.
122
123 =cut