From: Stevan Little Date: Sun, 6 Apr 2008 21:06:39 +0000 (+0000) Subject: what is done for isa should be done for does, so it was written! X-Git-Tag: 0_55~243 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2ea379cbea525bc561a5e7a72b7d12fd727ea43b;p=gitmo%2FMoose.git what is done for isa should be done for does, so it was written! --- diff --git a/Changes b/Changes index fbee72c..241d561 100644 --- a/Changes +++ b/Changes @@ -20,7 +20,7 @@ Revision history for Perl extension Moose * Moose::Meta::Attribute - inherited attributes may now be extended without - restriction on the type ('isa') (Sartak) + restriction on the type ('isa', 'does') (Sartak) - added tests for this (Sartak) - when an attribute property is malformed (such as lazy without a default), give the name of the attribute in the error diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 313c9f3..ad1822a 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -88,6 +88,24 @@ sub clone_and_inherit_options { $actual_options{type_constraint} = $type_constraint; delete $options{isa}; } + + if ($options{does}) { + my $type_constraint; + if (blessed($options{does}) && $options{does}->isa('Moose::Meta::TypeConstraint')) { + $type_constraint = $options{does}; + } + else { + $type_constraint = Moose::Util::TypeConstraints::find_or_create_type_constraint( + $options{does} + ); + (defined $type_constraint) + || confess "Could not find the type constraint '" . $options{does} . "'"; + } + + $actual_options{type_constraint} = $type_constraint; + delete $options{does}; + } + (scalar keys %options == 0) || confess "Illegal inherited options => (" . (join ', ' => keys %options) . ")"; $self->clone(%actual_options);