tags:

views:

147

answers:

1

I would like to use MooseX::ClassAttribute in a role. I.e., do something like

package Cachable;

use Moose::Role;
use MooseX::ClassAttribute;

class_has Cache => ( is => 'rw' );

1;

Unfortunately, the code above doesn't work as the deep magic of MooseX::ClassAttribute expects to be called from within a Moose object, and not a Moose::Role.
Is there any way to work around this, or is this a known limitation?

+2  A: 

You send me a patch that makes this work. It's certainly doable, although the Moose internals make it harder than it needs to be because of how roles handle attributes.

Dave Rolsky
Fair enough. I guess it's time for me to take a look at Moose's meta-goodness.
Yanick
Was there ever an update to this? I know I have run into the same limitation.
Danny
Patches are still welcome.
Dave Rolsky
@Dave: it would be helpful to have this limitation explicitly noted in the documentation.
Ether