File Coverage

blib/lib/Moose/Meta/Attribute/Native/Trait/Bool.pm
Criterion Covered Total %
statement 7 7 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 10 100.0


line stmt bran cond sub pod time code
1             package Moose::Meta::Attribute::Native::Trait::Bool;
2             our $VERSION = '2.2203';
3              
4 2     2   1289 use Moose::Role;
  2         7  
  2         19  
5             with 'Moose::Meta::Attribute::Native::Trait';
6              
7 35     35   166 sub _helper_type { 'Bool' }
8              
9 2     2   19 no Moose::Role;
  2         6  
  2         11  
10              
11             1;
12              
13             # ABSTRACT: Helper trait for Bool attributes
14              
15             __END__
16              
17             =pod
18              
19             =encoding UTF-8
20              
21             =head1 NAME
22              
23             Moose::Meta::Attribute::Native::Trait::Bool - Helper trait for Bool attributes
24              
25             =head1 VERSION
26              
27             version 2.2203
28              
29             =head1 SYNOPSIS
30              
31             package Room;
32             use Moose;
33              
34             has 'is_lit' => (
35             traits => ['Bool'],
36             is => 'rw',
37             isa => 'Bool',
38             default => 0,
39             handles => {
40             illuminate => 'set',
41             darken => 'unset',
42             flip_switch => 'toggle',
43             is_dark => 'not',
44             },
45             );
46              
47             my $room = Room->new();
48             $room->illuminate; # same as $room->is_lit(1);
49             $room->darken; # same as $room->is_lit(0);
50             $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
51             return $room->is_dark; # same as !$room->is_lit
52              
53             =head1 DESCRIPTION
54              
55             This trait provides native delegation methods for boolean values. A boolean is
56             a scalar which can be C<1>, C<0>, C<"">, or C<undef>.
57              
58             =head1 DEFAULT TYPE
59              
60             If you don't provide an C<isa> value for your attribute, it will default to
61             C<Bool>.
62              
63             =head1 PROVIDED METHODS
64              
65             None of these methods accept arguments.
66              
67             =over 4
68              
69             =item * B<set>
70              
71             Sets the value to C<1> and returns C<1>.
72              
73             =item * B<unset>
74              
75             Set the value to C<0> and returns C<0>.
76              
77             =item * B<toggle>
78              
79             Toggles the value. If it's true, set to false, and vice versa.
80              
81             Returns the new value.
82              
83             =item * B<not>
84              
85             Equivalent of 'not C<$value>'.
86              
87             =back
88              
89             =head1 BUGS
90              
91             See L<Moose/BUGS> for details on reporting bugs.
92              
93             =head1 AUTHORS
94              
95             =over 4
96              
97             =item *
98              
99             Stevan Little <stevan@cpan.org>
100              
101             =item *
102              
103             Dave Rolsky <autarch@urth.org>
104              
105             =item *
106              
107             Jesse Luehrs <doy@cpan.org>
108              
109             =item *
110              
111             Shawn M Moore <sartak@cpan.org>
112              
113             =item *
114              
115             יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
116              
117             =item *
118              
119             Karen Etheridge <ether@cpan.org>
120              
121             =item *
122              
123             Florian Ragwitz <rafl@debian.org>
124              
125             =item *
126              
127             Hans Dieter Pearcey <hdp@cpan.org>
128              
129             =item *
130              
131             Chris Prather <chris@prather.org>
132              
133             =item *
134              
135             Matt S Trout <mstrout@cpan.org>
136              
137             =back
138              
139             =head1 COPYRIGHT AND LICENSE
140              
141             This software is copyright (c) 2006 by Infinity Interactive, Inc.
142              
143             This is free software; you can redistribute it and/or modify it under
144             the same terms as the Perl 5 programming language system itself.
145              
146             =cut