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};
+ if (!exists $new_spec->{$key}) {
+ $new_spec->{$key} = $old_spec->{$key}
+ }
+ elsif ($key eq 'moosify') {
+ $new_spec->{$key} = [map { ref $_ eq 'ARRAY' ? @$_ : $_ } ($old_spec->{$key}, $new_spec->{$key})];
+ }
}
}
$new_spec->{index} = scalar keys %$specs
extends 'Plank';
}
+BEGIN {
+ package Plonk;
+ use Moo;
+ has kk => (is => 'rw', moosify => [sub {
+ $_[0]->{documentation} = 'parent';
+ }]);
+}
+BEGIN {
+ package Plonker;
+ use Moo;
+ extends 'Plonk';
+ has '+kk' => (moosify => sub {
+ my $spec = shift;
+ $spec->{documentation} .= 'child';
+ });
+}
+
foreach my $s (
Splattered->new,
Splattered2->new,
ok $c->can('has_splat');
}
-foreach my $c (Plunker->new) {
- is(Plunker->meta->find_attribute_by_name('pp')->documentation, 'moosify', 'moosify modifies attr specs');
- is(Planker->meta->find_attribute_by_name('vv')->documentation, 'moosify foo', 'moosify modifies attr specs as array');
-}
+is(Plunker->meta->find_attribute_by_name('pp')->documentation, 'moosify', 'moosify modifies attr specs');
+is(Planker->meta->find_attribute_by_name('vv')->documentation, 'moosify foo', 'moosify modifies attr specs as array');
+
+is( Plonker->meta->find_attribute_by_name('kk')->documentation,
+ 'parentchild',
+ 'moosify applies for overridden attributes with roles');
done_testing;