Subject: | example in Moose::Cookbook::Meta::Recipe5 generates error |
I tried running the example in the Synopsis section of
Moose::Cookbook::Meta::Recipe5. It generates this error:
Can't locate object method "table" via package
"Moose::Meta::Class::__ANON__::SERIAL::1" at
./work-scratch/moose-doodles.pl line 19.
Here's my code (verbatim from the cookbook):
###############
package MyApp::Meta::Class::Trait::HasTable;
use Moose::Role;
has table => (
is => 'rw',
isa => 'Str',
);
package Moose::Meta::Class::Custom::Trait::HasTable;
sub register_implementation { 'MyApp::Meta::Class::Trait::HasTable' }
package MyApp::User;
use Moose -traits => 'HasTable';
__PACKAGE__->meta->table('User');
###############
Since this doesn't work, can you tell me if this is the right approach?
Basically, I have a container object with roles. It has an attribute
which is an arrayref of objects of another class. I want to create the
container object with arbitrary roles as needed using MooseX::Traits.
The container roles need a meta attribute to specify what other roles
need to be applied to the objects in the arrayref to give them relevant
methods.
Thanks.
Mark