Class Attributes in roles?

[email protected] (Bernardo Rechea)
Newsgroups perl.moose
Message-ID <[email protected]>
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 think it would be useful if class attributes could be declared in roles in
the same way they are declared in classes.

Bernardo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.