X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FAttribute.pm;h=0083957a64676c4c87cf56225b241662f6c79ff5;hb=5e98d2b62deaddc3e3560b35d2fb2c0bc00f4635;hp=f8d539e98482128cd7965d4236b05d4226ab464b;hpb=6e2840b7f746179b3f3e4b02e8fafa9cd12804f4;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index f8d539e..0083957 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -65,31 +65,13 @@ sub clone_and_inherit_options { my ($self, %options) = @_; # you can change default, required, coerce, documentation and lazy my %actual_options; - foreach my $legal_option (qw(default coerce required documentation lazy)) { + foreach my $legal_option (qw(default coerce required documentation lazy handles builder)) { if (exists $options{$legal_option}) { $actual_options{$legal_option} = $options{$legal_option}; delete $options{$legal_option}; } } - # handles can only be added, not changed - if ($options{handles}) { - confess "You can only add the 'handles' option, you cannot change it" - if $self->has_handles; - $actual_options{handles} = $options{handles}; - delete $options{handles}; - } - - # handles can only be added, not changed - if ($options{builder}) { - confess "You can only add the 'builder' option, you cannot change it" - if $self->has_builder; - $actual_options{builder} = $options{builder}; - delete $options{builder}; - } - - # isa can be changed, but only if the - # new type is a subtype if ($options{isa}) { my $type_constraint; if (blessed($options{isa}) && $options{isa}->isa('Moose::Meta::TypeConstraint')) { @@ -102,14 +84,7 @@ sub clone_and_inherit_options { (defined $type_constraint) || confess "Could not find the type constraint '" . $options{isa} . "'"; } - # NOTE: - # check here to see if the new type - # is a subtype of the old one - ($type_constraint->is_subtype_of($self->type_constraint->name)) - || confess "New type constraint setting must be a subtype of inherited one" - # iff we have a type constraint that is ... - if $self->has_type_constraint; - # then we use it :) + $actual_options{type_constraint} = $type_constraint; delete $options{isa}; }