X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMethod%2FGenerate%2FConstructor.pm;h=e0746d7a41613d79d20e2313b4c7ce4b20812465;hb=9f10cfe08cb754b4cdb85c1ac771606fbb98c770;hp=9dae34b53fc93da70a3b657b5b984274373befd6;hpb=6067158cf3146f758b7975688b2ac124f2992a34;p=gitmo%2FMoo.git diff --git a/lib/Method/Generate/Constructor.pm b/lib/Method/Generate/Constructor.pm index 9dae34b..e0746d7 100644 --- a/lib/Method/Generate/Constructor.pm +++ b/lib/Method/Generate/Constructor.pm @@ -10,6 +10,14 @@ sub register_attribute_specs { my ($self, @new_specs) = @_; my $specs = $self->{attribute_specs}||={}; while (my ($name, $new_spec) = splice @new_specs, 0, 2) { + if ($name =~ s/^\+//) { + die "has '+${name}' given but no ${name} attribute already exists" + unless my $old_spec = $specs->{$name}; + foreach my $key (keys %$old_spec) { + $new_spec->{$key} = $old_spec->{$key} + unless exists $new_spec->{$key}; + } + } $new_spec->{index} = scalar keys %$specs unless defined $new_spec->{index}; $specs->{$name} = $new_spec;