Commit | Line | Data |
b95d9f9b |
1 | package MooseX::SemiAffordanceAccessor; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | our $VERSION = '0.03'; |
7 | |
1a0388e6 |
8 | use Moose 0.5504 (); |
b95d9f9b |
9 | use Moose::Exporter; |
10 | use Moose::Util::MetaRole; |
11 | use MooseX::SemiAffordanceAccessor::Role::Attribute; |
12 | |
13 | # The main reason to use this is to ensure that we get the right value |
14 | # in $p{for_class} later. |
15 | Moose::Exporter->setup_import_methods(); |
16 | |
b95d9f9b |
17 | sub init_meta |
18 | { |
19 | shift; |
20 | my %p = @_; |
21 | |
22 | Moose->init_meta(%p); |
23 | |
24 | return |
25 | Moose::Util::MetaRole::apply_metaclass_roles |
26 | ( for_class => $p{for_class}, |
27 | attribute_metaclass_roles => |
28 | ['MooseX::SemiAffordanceAccessor::Role::Attribute'], |
29 | ); |
30 | } |
31 | |
b95d9f9b |
32 | 1; |
33 | |
34 | __END__ |
35 | |
36 | =pod |
37 | |
38 | =head1 NAME |
39 | |
40 | MooseX::SemiAffordanceAccessor - Name your accessors foo() and set_foo() |
41 | |
42 | =head1 SYNOPSIS |
43 | |
44 | use MooseX::SemiAffordanceAccessor; |
45 | use Moose; |
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 AUTHOR |
66 | |
67 | Dave Rolsky, C<< <autarch@urth.org> >> |
68 | |
69 | =head1 BUGS |
70 | |
71 | Please report any bugs or feature requests to |
72 | C<bug-moosex-semiaffordanceaccessor@rt.cpan.org>, or through |
73 | the web interface at L<http://rt.cpan.org>. I will be notified, and |
74 | then you'll automatically be notified of progress on your bug as I |
75 | make changes. |
76 | |
77 | =head1 COPYRIGHT & LICENSE |
78 | |
31d1505c |
79 | Copyright 2007-2008 Dave Rolsky, All Rights Reserved. |
b95d9f9b |
80 | |
81 | This program is free software; you can redistribute it and/or modify |
82 | it under the same terms as Perl itself. |
83 | |
84 | =cut |