RW
[gitmo/MooseX-IsDefaults.git] / lib / MooseX / IsDefaults / Meta / IsRW.pm
diff --git a/lib/MooseX/IsDefaults/Meta/IsRW.pm b/lib/MooseX/IsDefaults/Meta/IsRW.pm
new file mode 100644 (file)
index 0000000..ce692e6
--- /dev/null
@@ -0,0 +1,25 @@
+package MooseX::IsDefaults::Meta::IsRW;
+use Moose::Role;
+
+# This does not actually do anything but lie less in the attribute's metadata.
+has '+is' => (
+    default => 'rw',
+);
+
+around _process_options => sub {
+    my $orig = shift;
+    my (undef, undef, $options) = @_;
+
+    if (!exists($options->{is})) {
+        $options->{is} = 'rw';
+    }
+    # They want no accessor, but Moose doesn't like "is => undef"
+    elsif (!defined($options->{is})) {
+        delete $options->{is};
+    }
+
+    $orig->(@_);
+};
+
+1;
+