lib/Moose/Policy/FollowPBP.pm - POD spelling/wording
[gitmo/Moose-Policy.git] / lib / Moose / Policy / FollowPBP.pm
CommitLineData
461dc6d3 1
2package Moose::Policy::FollowPBP;
3
4use constant attribute_metaclass => 'Moose::Policy::FollowPBP::Attribute';
5
6package Moose::Policy::FollowPBP::Attribute;
7use Moose;
8
9extends 'Moose::Meta::Attribute';
10
11before '_process_options' => sub {
12 my ($class, $name, $options) = @_;
13 # NOTE:
14 # If is has been specified, and
15 # we don't have a reader or writer
16 # Of couse this is an odd case, but
17 # we better test for it anyway.
18 if (exists $options->{is} && !(exists $options->{reader} || exists $options->{writer})) {
19 if ($options->{is} eq 'ro') {
20 $options->{reader} = 'get_' . $name;
21 }
22 elsif ($options->{is} eq 'rw') {
23 $options->{reader} = 'get_' . $name;
24 $options->{writer} = 'set_' . $name;
25 }
26 delete $options->{is};
27 }
28};
29
301;
31
32__END__
33
34=pod
35
09eff61e 36=head1 NAME
37
38Moose::Policy::FollowPBP - Follow the recomendations in Perl Best Practices
39
40=head1 SYNOPSIS
41
42 package Foo;
43
44 use Moose::Policy 'Moose::Policy::FollowPBP';
45 use Moose;
46
47 has 'bar' => (is => 'rw', default => 'Foo::bar');
48 has 'baz' => (is => 'ro', default => 'Foo::baz');
49
50 # Foo now has (get, set)_bar methods as well as get_baz
51
52=head1 DESCRIPTION
53
04f7377e 54This meta-policy changes Moose's default accossor-naming behavior to
55follow the recommendations found in Damian Conway's book I<Perl Best
56Practices>.
09eff61e 57
58=head1 BUGS
59
04f7377e 60All complex software has bugs lurking in it, and this module is no
09eff61e 61exception. If you find a bug please either email me, or add the bug
62to cpan-RT.
63
64=head1 AUTHOR
65
66Stevan Little E<lt>stevan@iinteractive.comE<gt>
67
68=head1 COPYRIGHT AND LICENSE
69
70Copyright 2006 by Infinity Interactive, Inc.
71
72L<http://www.iinteractive.com>
73
74This library is free software; you can redistribute it and/or modify
75it under the same terms as Perl itself.
76
461dc6d3 77=cut