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