From: Stevan Little Date: Fri, 4 Jul 2008 03:48:41 +0000 (+0000) Subject: 0.54 X-Git-Tag: 0_55~52 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=713b0244d34d5ef472077ce5913dfe0d1daa958d;p=gitmo%2FMoose.git 0.54 --- diff --git a/Changes b/Changes index 5ccfd3a..ae695e2 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,14 @@ Revision history for Perl extension Moose -0.54 +0.54 Thurs. July 3, 2008 + ... this is not my day today ... + + * Moose::Meta::Attribute + - fixed legal_options_for_inheritance such that + clone_and_inherit options still works for + Class::MOP::Attribute objects and therefore + does not break MooseX::AttributeHelpers + (stevan) 0.53 Thurs. July 3, 2008 * Whoops, I guess I should run 'make manifest' before diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 155f9a0..387a88f 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -116,22 +116,54 @@ sub interpolate_class { return ( wantarray ? ( $class, @traits ) : $class ); } -# you can change default, required, coerce, documentation, lazy, handles, builder, type_constraint (explicitly or using isa/does), metaclass and traits -sub legal_options_for_inheritance { - return qw(default coerce required documentation lazy handles builder - type_constraint); -} - +# ... + +my @legal_options_for_inheritance = qw( + default coerce required + documentation lazy handles + builder type_constraint +); + +sub legal_options_for_inheritance { @legal_options_for_inheritance } + +# NOTE/TODO +# This method *must* be able to handle +# Class::MOP::Attribute instances as +# well. Yes, I know that is wrong, but +# apparently we didn't realize it was +# doing that and now we have some code +# which is dependent on it. The real +# solution of course is to push this +# feature back up into Class::MOP::Attribute +# but I not right now, I am too lazy. +# However if you are reading this and +# looking for something to do,.. please +# be my guest. +# - stevan sub clone_and_inherit_options { my ($self, %options) = @_; + my %copy = %options; + my %actual_options; - foreach my $legal_option ($self->legal_options_for_inheritance) { + + # NOTE: + # we may want to extends a Class::MOP::Attribute + # in which case we need to be able to use the + # core set of legal options that have always + # been here. But we allows Moose::Meta::Attribute + # instances to changes them. + # - SL + my @legal_options = $self->can('legal_options_for_inheritance') + ? $self->legal_options_for_inheritance + : @legal_options_for_inheritance; + + foreach my $legal_option (@legal_options) { if (exists $options{$legal_option}) { $actual_options{$legal_option} = $options{$legal_option}; delete $options{$legal_option}; } - } + } if ($options{isa}) { my $type_constraint;