Add my name to spelling whitelist
[gitmo/MooseX-FollowPBP.git] / lib / MooseX / FollowPBP / Role / Attribute.pm
CommitLineData
a623c113 1package MooseX::FollowPBP::Role::Attribute;
2
3use strict;
4use warnings;
5
6use Moose::Role;
7
73198536 8before _process_options => sub {
a623c113 9 my $class = shift;
10 my $name = shift;
11 my $options = shift;
12
7e7ad65a 13 if ( exists $options->{is}
14 && !( exists $options->{reader} || exists $options->{writer} )
15 && $options->{is} ne 'bare' ) {
a623c113 16 my $get;
17 my $set;
18
73198536 19 if ( $name =~ s/^_// ) {
a623c113 20 $get = '_get_';
21 $set = '_set_';
22 }
73198536 23 else {
a623c113 24 $get = 'get_';
25 $set = 'set_';
26 }
27
28 $options->{reader} = $get . $name;
29
73198536 30 if ( $options->{is} eq 'rw' ) {
a623c113 31 $options->{writer} = $set . $name;
32 }
33
34 delete $options->{is};
35 }
36};
37
38no Moose::Role;
39
401;
41
42=head1 SYNOPSIS
43
00ccc022 44 Moose::Util::MetaRole::apply_metaclass_roles(
45 for => $p{for_class},
46 class_metaroles => {
47 attribute => ['MooseX::FollowPBP::Role::Attribute'],
48 },
49 );
a623c113 50
51=head1 DESCRIPTION
52
53This role applies a method modifier to the C<_process_options()>
54method, and tweaks the reader and writer parameters so that they
55follow the style recommended in I<Perl Best Practices>.
56
57=cut
58