Add deprecation notices to all modules
[gitmo/Moose-Policy.git] / lib / Moose / Policy / JavaAccessors.pm
CommitLineData
08e608bd 1
2package Moose::Policy::JavaAccessors;
3
4use constant attribute_metaclass => 'Moose::Policy::JavaAccessors::Attribute';
5
6package Moose::Policy::JavaAccessors::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' . ucfirst($name);
21 }
22 elsif ($options->{is} eq 'rw') {
23 $options->{reader} = 'get' . ucfirst($name);
24 $options->{writer} = 'set' . ucfirst($name);
25 }
26 delete $options->{is};
27 }
28};
29
301;
31
32__END__
33
34=pod
35
09eff61e 36=head1 NAME
37
38Moose::Policy::JavaAccessors - BeCause EveryOne Loves CamelCase
39
40=head1 SYNOPSIS
41
42 package Foo;
43
44 use Moose::Policy 'Moose::Policy::JavaAccessors';
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 getBaz
51
3d1dec0a 52=head1 DEPRECATION NOTICE
53
54B<Moose::Policy is deprecated>.
55
09eff61e 56=head1 DESCRIPTION
57
58This meta-policy changes the behavior of Moose's default behavior in
59regard to accessors to follow Java convention and use CamelCase.
60
61=head1 CAVEAT
62
63This does a very niave conversion to CamelCase, basically it just
64runs C<ucfirst> on the attribute name. Since I don't use CamelCase
65(at least not anymore), this is good enough. If you really want to
66use this, and need a more sophisicated conversion, patches welcome :)
67
68=head1 BUGS
69
70All complex software has bugs lurking in it, and this module is no
71exception. If you find a bug please either email me, or add the bug
72to cpan-RT.
73
74=head1 AUTHOR
75
76Stevan Little E<lt>stevan@iinteractive.comE<gt>
77
78=head1 COPYRIGHT AND LICENSE
79
4fe62f68 80Copyright 2006-2007 by Infinity Interactive, Inc.
09eff61e 81
82L<http://www.iinteractive.com>
83
84This library is free software; you can redistribute it and/or modify
85it under the same terms as Perl itself.
86
08e608bd 87=cut