Generally I have noticed the before modifier is carried through inheritance,
however I have come across a scenario where this does not seem to be the
case.

The case is where the before modifier is applied to a 'provides' installed
method, which is then adjusted using the 'has +$var' syntax. For some
reason, objects of the extended class no longer see the before modifier. See
code below if none of that made sense.

Is this 'feature' intentional? (actually I am hoping someone will say it is
a bug ;-) It threw a big spanner in the works of an otherwise very elegant
and compact object hierarchy. Sorry if there was something glaringly obvious
in the documentation explaining this...

#!/usr/bin/perl -w

package Foo;
use Moose;
use MooseX::AttributeHelpers;

has things => (is  => 'rw'
              ,isa => 'ArrayRef[Str]'
              ,metaclass => 'Collection::Array'
              ,default   => sub { [] }
              ,provides  => {
                push => 'add_thing'
              }
);

before add_thing => sub { warn "before\n" };

1;

package Bar;
use Moose;

extends 'Foo';

has '+things' => (lazy => 1);

1;

my $list1 = new Foo;
my $list2 = new Bar;

$list1->add_thing("bob");  // This line results in 'before' being printed
$list2->add_thing("jim");   // This line does not!

Reply via email to