Class::MOP::Attribute->meta->add_method('clone' => sub {
my $self = shift;
- $self->meta->clone_object($self, @_);
+ Class::MOP::get_meta($self)->clone_object($self, @_);
});
## --------------------------------------------------------
Class::MOP::Method->meta->add_method('clone' => sub {
my $self = shift;
- my $clone = $self->meta->clone_object($self, @_);
+ my $clone = Class::MOP::get_meta($self)->clone_object($self, @_);
$clone->_set_original_method($self);
return $clone;
});
# it is safe to use meta here because
# class will always be a subclass of
# Class::MOP::Class, which defines meta
- $meta = $class->meta->construct_instance($options)
+ $meta = $class->meta->construct_instance($options);
}
# and check the metaclass compatibility
my $old_metaclass;
if ($instance->can('meta')) {
- ($instance->meta->isa('Class::MOP::Class'))
- || confess 'Cannot rebless instance if ->meta is not an instance of Class::MOP::Class';
- $old_metaclass = $instance->meta;
+ $old_metaclass = Class::MOP::get_meta($instance);
+ ($old_metaclass->isa('Class::MOP::Class'))
+ || confess 'Cannot rebless instance if the metaclass is not an instance of Class::MOP::Class';
}
else {
$old_metaclass = $self->initialize(ref($instance));
# that has been made immutable and for that we need
# to dig a bit ...
if ($self->isa('Class::MOP::Class')) {
- return $self->{'___original_class'}->meta;
+ return Class::MOP::get_meta($self->{'___original_class'});
}
else {
return $self;
my %methods = %DEFAULT_METHODS;
my $metaclass = $self->metaclass;
- my $meta = $metaclass->meta;
+ my $meta = Class::MOP::get_meta($metaclass);
$methods{get_mutable_metaclass_name}
= sub { (shift)->{'___original_class'} };
}
sub _new {
- shift->meta->new_object(@_);
+ Class::MOP::get_meta(shift)->new_object(@_);
}
# RANT: