When MyRole is composed into a class. I want it to fiddle with the attributes of the class while it is being built.
On Tue, 2011-10-18 at 11:41 -0400, Chris Prather wrote: > On Tue, Oct 18, 2011 at 11:02 AM, Peter Gordon <pe...@pg-consultants.com> > wrote: > > This is the example I am working with: > > > > package MyRole ; > > with Moose::Role ; > > > > # Operate on the 'has' items > > sub runMe { > > } > > > > package X ;around BUILD => \&runMe; > > use Moose ; > > has 'item' => ( is => 'rw' , isa => 'Str') ; > > > > > > package Y ; > > use Moose ; > > extends 'X' ; > > with 'MyRole'; > > > > > > I would like to be able to define package MyRole such that when it is > > invoked, runMe() gets run automatically without having to run > > it explicitly in package Y. > > How do you mean "invoked"? Do you mean when an object is created from > a class that composes MyRole? > > package MyRole; > use Moose::Role; > > sub BUILD { } > around BUILD => \&runMe; > > > If you mean when MyRole is composed into a class, that's different. > > -Chris