Make sure is => undef works
[gitmo/MooseX-HasDefaults.git] / lib / MooseX / IsDefaults / Meta / IsRW.pm
1 package MooseX::IsDefaults::Meta::IsRW;
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 => 'rw',
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} = 'rw';
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