File Coverage

blib/lib/MooseX/SemiAffordanceAccessor.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 26 26 100.0


line stmt bran cond sub pod time code
1             package MooseX::SemiAffordanceAccessor;
2             BEGIN {
3 2     2   2113062 $MooseX::SemiAffordanceAccessor::VERSION = '0.09';
4             }
5              
6 2     2   18 use strict;
  2         6  
  2         68  
7 2     2   10 use warnings;
  2         4  
  2         65  
8              
9 2     2   16 use Moose 0.94 ();
  2         215  
  2         52  
10 2     2   13 use Moose::Exporter;
  2         5  
  2         18  
11 2     2   107 use Moose::Util::MetaRole;
  2         5  
  2         49  
12 2     2   2494 use MooseX::SemiAffordanceAccessor::Role::Attribute;
  2         7  
  2         215  
13              
14             my %metaroles = (
15             class_metaroles => {
16             attribute => ['MooseX::SemiAffordanceAccessor::Role::Attribute'],
17             },
18             );
19              
20             $metaroles{role_metaroles} = {
21             applied_attribute => ['MooseX::SemiAffordanceAccessor::Role::Attribute'],
22             } if $Moose::VERSION >= 1.9900;
23              
24             Moose::Exporter->setup_import_methods(%metaroles);
25              
26             1;
27              
28             # ABSTRACT: Name your accessors foo() and set_foo()
29              
30              
31              
32             =pod
33              
34             =head1 NAME
35              
36             MooseX::SemiAffordanceAccessor - Name your accessors foo() and set_foo()
37              
38             =head1 VERSION
39              
40             version 0.09
41              
42             =head1 SYNOPSIS
43              
44             use Moose;
45             use MooseX::SemiAffordanceAccessor;
46              
47             # make some attributes
48              
49             =head1 DESCRIPTION
50              
51             This module does not provide any methods. Simply loading it changes
52             the default naming policy for the loading class so that accessors are
53             separated into get and set methods. The get methods have the same name
54             as the accessor, while set methods are prefixed with "set_".
55              
56             If you define an attribute with a leading underscore, then the set
57             method will start with "_set_".
58              
59             If you explicitly set a "reader" or "writer" name when creating an
60             attribute, then that attribute's naming scheme is left unchanged.
61              
62             The name "semi-affordance" comes from David Wheeler's Class::Meta
63             module.
64              
65             =head1 ACCESSORS IN ROLES
66              
67             Prior to version 1.9900 of L<Moose>, attributes added to a class ended up with
68             that class's attribute traits. That means that if your class used
69             C<MooseX::SemiAffordanceAccessor>, any attributes provided by roles you
70             consumed had the semi-affordance style of accessor.
71              
72             As of Moose 1.9900, that is no longer the case. Attributes provided by roles
73             no longer acquire the consuming class's attribute traits. However, with Moose
74             1.9900+, you can now use C<MooseX::SemiAffordanceAccessor> directly in
75             roles. Attributes defined by that role will have semi-affordance style
76             accessors, regardless of what attribute traits the consuming class has.
77              
78             =head1 BUGS
79              
80             Please report any bugs or feature requests to
81             C<bug-moosex-semiaffordanceaccessor@rt.cpan.org>, or through
82             the web interface at L<http://rt.cpan.org>. I will be notified, and
83             then you'll automatically be notified of progress on your bug as I
84             make changes.
85              
86             =head1 AUTHOR
87              
88             Dave Rolsky <autarch@urth.org>
89              
90             =head1 COPYRIGHT AND LICENSE
91              
92             This software is Copyright (c) 2011 by Dave Rolsky.
93              
94             This is free software, licensed under:
95              
96             The Artistic License 2.0 (GPL Compatible)
97              
98             =cut
99              
100              
101             __END__
102