Commit | Line | Data |
0413c7e1 |
1 | package MooseX::IsDefaults::Meta::IsRO; |
2 | use Moose::Role; |
3 | |
4 | # This does not actually do anything but lie less in the attribute's metadata. |
5 | has '+is' => ( |
6 | default => 'ro', |
7 | ); |
8 | |
9 | around _process_options => sub { |
10 | my $orig = shift; |
11 | my (undef, undef, $options) = @_; |
12 | |
13 | if (!exists($options->{is})) { |
14 | $options->{is} = 'ro'; |
15 | } |
16 | # They want no accessor, but Moose doesn't like "is => undef" |
17 | elsif (!defined($options->{is})) { |
18 | delete $options->{is}; |
19 | } |
20 | |
21 | $orig->(@_); |
22 | }; |
23 | |
24 | 1; |
25 | |