From: Matt S Trout Date: Fri, 24 Jul 2009 16:10:23 +0000 (+0100) Subject: make weak_ref permitted as part of attribute inheritance X-Git-Tag: 0.88~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d7e7abd922c072bb83b4c407d11c35ad45e28aa9;p=gitmo%2FMoose.git make weak_ref permitted as part of attribute inheritance --- diff --git a/Changes b/Changes index 78b6653..458e00b 100644 --- a/Changes +++ b/Changes @@ -23,6 +23,8 @@ for, noteworthy changes. (rafl) * Moose::Util::MetaRole - Allow applying roles to a meta role's role application classes. (rafl) + * Moose::Meta::Attribute + - add weak_ref to allowed options for "has '+foo'" (mst) 0.87 Tue Jul 7, 2009 * Moose::Meta::Method::Delegation diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index e6d9990..5cb22a7 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -163,7 +163,7 @@ my @legal_options_for_inheritance = qw( documentation lazy handles builder type_constraint definition_context - lazy_build + lazy_build weak_ref ); sub legal_options_for_inheritance { @legal_options_for_inheritance } diff --git a/t/020_attributes/009_attribute_inherited_slot_specs.t b/t/020_attributes/009_attribute_inherited_slot_specs.t index 7903f9d..62c1958 100644 --- a/t/020_attributes/009_attribute_inherited_slot_specs.t +++ b/t/020_attributes/009_attribute_inherited_slot_specs.t @@ -33,6 +33,7 @@ use Test::Exception; has 'gorch' => (is => 'ro'); has 'gloum' => (is => 'ro', default => sub {[]}); + has 'fleem' => (is => 'ro'); has 'bling' => (is => 'ro', isa => 'Thing'); has 'blang' => (is => 'ro', isa => 'Thing', handles => ['goodbye']); @@ -88,6 +89,10 @@ use Test::Exception; } '... now can extend an attribute with a non-subtype'; ::lives_ok { + has '+fleem' => (weak_ref => 1); + } '... now allowed to add the weak_ref option via inheritance'; + + ::lives_ok { has '+bling' => (handles => ['hello']); } '... we can add the handles attribute option'; @@ -101,9 +106,6 @@ use Test::Exception; ::dies_ok { has '+other_fail' => (trigger => sub {}); } '... cannot create an attribute with an illegal option'; - ::dies_ok { - has '+other_fail' => (weak_ref => 1); - } '... cannot create an attribute with an illegal option'; ::throws_ok { has '+does_not_exist' => (isa => 'Str'); } qr/in Bar/, '... cannot extend a non-existing attribute';