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