use Moose::Role;
use Class::MOP;
+use Class::MOP::Object;
use Scalar::Util 'blessed';
sub mk_classdata {
my $slot = '$'.$attribute;
my $accessor = sub {
- my $meta = $_[0]->meta;
my $pkg = ref $_[0] || $_[0];
- if(@_ > 1){
+ my $meta = $pkg->Class::MOP::Object::meta();
+ if (@_ > 1) {
$meta->namespace->{$attribute} = \$_[1];
return $_[1];
}
foreach my $super ( $meta->linearized_isa ) {
# tighter version of same after
# my $super_meta = Moose::Meta::Class->initialize($super);
- my $v = *{"${super}::${attribute}"}{SCALAR};
+ my $v = ${"${super}::"}{$attribute} ? *{"${super}::${attribute}"}{SCALAR} : undef;
if (defined ${$v}) {
return ${$v};
}
confess("Failed to create accessor: $@ ")
unless ref $accessor eq 'CODE';
- my $meta = $class->meta;
+ my $meta = $class->Class::MOP::Object::meta();
my $immutable_options;
if( $meta->is_immutable ){
$immutable_options = $meta->get_immutable_options;
$meta->add_method($alias, $accessor);
$meta->add_method($attribute, $accessor);
if(defined $immutable_options){
- $meta->make_immutable($immutable_options);
+ $meta->make_immutable(%{ $immutable_options });
}
$class->$attribute($_[2]) if(@_ > 2);
return $accessor;