Re: Class Attributes in roles?
[email protected] (Dave Rolsky)
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 19 May 2008, Bernardo Rechea wrote:
> Code like this:
>
> ---------------------------------------------------------------------
> #!/usr/bin/env perl
>
> {
> package RoleFoo;
> use Moose::Role;
> use MooseX::ClassAttribute;
>
> class_has 'fooAttr' => ( is => 'rw' ); # this doesn't.
> }
> {
> package ClassBar;
> use Moose;
> with 'RoleFoo';
>
> has 'barAttr' => ( is => 'rw' );
> }
>
> my $bar = ClassBar->new(barAttr => 'dummy');
> print "barAttr: ", $bar->barAttr, "\n";
> ---------------------------------------------------------------------
>
> Gives this error:
>
> "Can't locate object method "superclasses" via package "Moose::Meta::Role"
> at /home/brb/localperl/lib/site_perl/5.10.0/MooseX/ClassAttribute.pm line
> 32."
I'm not surprised.
> I think it would be useful if class attributes could be declared in roles in
> the same way they are declared in classes.
Probably.
Patches welcome ;)
-dave
/*==========================
VegGuide.Org
Your guide to all that's veg
==========================*/