parameter foo => (is => 'rw', builder => '_foo');

with _foo() defined above this statement, below it, inside the role
block (pretty sure it fails before getting inside the role).  No
good.  It says: Error:  Class::MOP::Class::__ANON__::SERIAL::1 does
not support builder method ...


You should have the builder method defined outside the role {} block, i.e.
at the same level as the parameter declaration itself.

Can you give an example where you would need to define the builder inside
the role block? This sounds rather strange to me.

HI Karen, thanks for the help.
No reason for the builder to be inside the role{} block. I was just trying everything to make it work.

Here is the most straightforward approach that fails with the error above (the error occurs while trying to use Me):

package Role;
use MooseX::Role::Parameterized;

sub _type{  'human'; }

parameter 'type' =>(
   isa => 'Str',
   required => 0,
   builder => '_type',
);
role{
   my $p = shift;
   my $type = $p->type;
   has $type =>(is => 'rw');
};

1;

package Me;
use Moose;
with 'Role' => { };
1;

Reply via email to