use Moose::Role;
use Class::MOP;
use Class::MOP::Object;
-use Scalar::Util 'blessed';
sub mk_classdata {
my ($class, $attribute) = @_;
my $slot = '$'.$attribute;
my $accessor = sub {
my $pkg = ref $_[0] || $_[0];
+ # Hack - delberately create a metaclass instance
my $meta = $pkg->Class::MOP::Object::meta();
- if (@_ > 1){
+ if (@_ > 1) {
$meta->namespace->{$attribute} = \$_[1];
return $_[1];
}
return ${$v};
} else {
foreach my $super ( $meta->linearized_isa ) {
- # If there is a code symbol for this attr in a parent class,
- # then copy it into our package. Is this the correct
- # fix for C::D::I back-compat? (t0m)
- my $parent_symbol = *{"${super}::${attribute}"}{CODE} ? \&{"${super}::${attribute}"} : undef;
- if (defined $parent_symbol) {
- *{"${pkg}::${attribute}"} = $parent_symbol;
- }
# tighter version of same after
# my $super_meta = Moose::Meta::Class->initialize($super);
my $v = ${"${super}::"}{$attribute} ? *{"${super}::${attribute}"}{SCALAR} : undef;
unless ref $accessor eq 'CODE';
my $meta = $class->Class::MOP::Object::meta();
+ confess "${class}'s metaclass is not a Class::MOP::Class"
+ unless $meta->isa('Class::MOP::Class');
my $immutable_options;
if( $meta->is_immutable ){
$immutable_options = $meta->get_immutable_options;
=head1 NAME
-Catalyst::ClassData - Class data acessors
+Catalyst::ClassData - Class data accessors
=head1 METHODS