Default parameters to read-only
[gitmo/MooseX-Role-Parameterized.git] / lib / MooseX / Role / Parameterized / Meta / Parameter.pm
index 29fc918..a37f643 100644 (file)
@@ -2,9 +2,25 @@ package MooseX::Role::Parameterized::Meta::Parameter;
 use Moose;
 extends 'Moose::Meta::Attribute';
 
+# This doesn't actually do anything because _process_options does not consult
+# the default value of "is". hrm.
+has '+is' => (
+    default => 'ro',
+);
 
+around _process_options => sub {
+    my $orig = shift;
+    my ($class, $name, $options) = @_;
 
-__PACKAGE__->meta->make_immutable;
+    $options->{is} ||= 'ro';
+
+    $orig->(@_);
+};
+
+__PACKAGE__->meta->make_immutable(
+    inline_constructor => 1,
+    constructor_name   => "_new",
+);
 no Moose;
 
 1;