Commit | Line | Data |
b95d9f9b |
1 | package MooseX::SemiAffordanceAccessor; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
7891bc29 |
6 | use Moose 0.94 (); |
b95d9f9b |
7 | use Moose::Exporter; |
8 | use Moose::Util::MetaRole; |
9 | use MooseX::SemiAffordanceAccessor::Role::Attribute; |
10 | |
8a1964e9 |
11 | my %metaroles = ( |
5177f5e0 |
12 | class_metaroles => { |
13 | attribute => ['MooseX::SemiAffordanceAccessor::Role::Attribute'], |
14 | }, |
15 | ); |
b95d9f9b |
16 | |
8a1964e9 |
17 | $metaroles{role_metaroles} = { |
18 | applied_attribute => ['MooseX::SemiAffordanceAccessor::Role::Attribute'], |
19 | } if $Moose::VERSION >= 1.9900; |
20 | |
21 | Moose::Exporter->setup_import_methods(%metaroles); |
22 | |
b95d9f9b |
23 | 1; |
24 | |
5177f5e0 |
25 | # ABSTRACT: Name your accessors foo() and set_foo() |
26 | |
b95d9f9b |
27 | __END__ |
28 | |
29 | =pod |
30 | |
b95d9f9b |
31 | =head1 SYNOPSIS |
32 | |
b95d9f9b |
33 | use Moose; |
8d547f46 |
34 | use MooseX::SemiAffordanceAccessor; |
b95d9f9b |
35 | |
36 | # make some attributes |
37 | |
38 | =head1 DESCRIPTION |
39 | |
40 | This module does not provide any methods. Simply loading it changes |
41 | the default naming policy for the loading class so that accessors are |
42 | separated into get and set methods. The get methods have the same name |
43 | as the accessor, while set methods are prefixed with "set_". |
44 | |
45 | If you define an attribute with a leading underscore, then the set |
46 | method will start with "_set_". |
47 | |
48 | If you explicitly set a "reader" or "writer" name when creating an |
49 | attribute, then that attribute's naming scheme is left unchanged. |
50 | |
51 | The name "semi-affordance" comes from David Wheeler's Class::Meta |
52 | module. |
53 | |
42333964 |
54 | =head1 ACCESSORS IN ROLES |
55 | |
56 | Prior to version 1.9900 of L<Moose>, attributes added to a class ended up with |
57 | that class's attribute traits. That means that if your class used |
58 | C<MooseX::SemiAffordanceAccessor>, any attributes provided by roles you |
59 | consumed had the semi-affordance style of accessor. |
60 | |
61 | As of Moose 1.9900, that is no longer the case. Attributes provided by roles |
62 | no longer acquire the consuming class's attribute traits. However, with Moose |
63 | 1.9900+, you can now use C<MooseX::SemiAffordanceAccessor> directly in |
64 | roles. Attributes defined by that role will have semi-affordance style |
65 | accessors, regardless of what attribute traits the consuming class has. |
66 | |
b95d9f9b |
67 | =head1 BUGS |
68 | |
69 | Please report any bugs or feature requests to |
70 | C<bug-moosex-semiaffordanceaccessor@rt.cpan.org>, or through |
71 | the web interface at L<http://rt.cpan.org>. I will be notified, and |
72 | then you'll automatically be notified of progress on your bug as I |
73 | make changes. |
74 | |
b95d9f9b |
75 | =cut |