Commit | Line | Data |
461dc6d3 |
1 | |
2 | package Moose::Policy::FollowPBP; |
3 | |
4 | use constant attribute_metaclass => 'Moose::Policy::FollowPBP::Attribute'; |
5 | |
6 | package Moose::Policy::FollowPBP::Attribute; |
7 | use Moose; |
8 | |
9 | extends 'Moose::Meta::Attribute'; |
10 | |
11 | before '_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 | |
30 | 1; |
31 | |
32 | __END__ |
33 | |
34 | =pod |
35 | |
36 | =cut |