---------- Forwarded message ----------
Date: Sat, 3 Apr 2010 08:40:29 -0700
From: Larry Marso <[email protected]>
To: [email protected]
Subject: Moose Meta cookbook recipe 5 broken (attribute as metaclass trait)
broken in Moose 1.01?
something about reader/writer methods changing?
fyi, with Moose 1.01, running your recipe 5 from moose meta cookbook I get:
Can't locate object method "table" via package
"Class::MOP::Class::__ANON__::SERIAL::1" at line 15.
code:
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');
something similar running shawn moore's code from YAPC:NA presentation:
Can't locate object method "count" via package
"Class::MOP::Class::__ANON__::SERIAL::1" at test.pl line 40.
code:
#!/usr/bin/perl
use strict;
use warnings;
use feature ':5.10';
package HasCounter;
use Moose::Role;
has count => (
is => 'rw',
isa => 'Int',
default => 0,
);
sub increment {
my $self = shift;
$self->count(
$self->count + 1
);
}
package CountInstances;
use Moose::Role;
with 'HasCounter';
after new_object => sub {
my $self = shift;
$self->increment;
};
package Point::Dot;
use Moose -traits => 'HasCounter';
has x => (
is => 'ro',
isa => 'Int',
);
Point::Dot->meta->count; # 0
Point::Dot->new;
Point::Dot->meta->count; # 1
Point::Dot->new for 1 .. 5;
Point::Dot->meta->count; # 6