$method_ctx = { %$ctx };
}
+ my $metaclass = $self->associated_class;
+
if (ref($accessor)) {
(ref($accessor) eq 'HASH')
|| confess "bad accessor/reader/writer/predicate/clearer format, must be a HASH ref";
my ($name, $method) = %{$accessor};
+
$method = $self->accessor_metaclass->wrap(
- $method,
- package_name => $self->associated_class->name,
- name => $name,
- definition_context => $method_ctx,
+ body => $method,
+ associated_metaclass => $metaclass,
+ package_name => $metaclass->name,
+ name => $name,
+ definition_context => $method_ctx,
);
$self->associate_method($method);
return ($name, $method);
}
$method = $self->accessor_metaclass->new(
- attribute => $self,
- accessor_type => $type,
- package_name => $self->associated_class->name,
- name => $accessor,
- definition_context => $method_ctx,
+ attribute => $self,
+ accessor_type => $type,
+ associated_metaclass => $metaclass,
+ package_name => $metaclass->name,
+ name => $accessor,
+ definition_context => $method_ctx,
);
};
confess "Could not create the '$type' method for " . $self->name . " because : $@" if $@;
# a cycle in the code, if not
# needed
weaken($self->{'attribute'});
+ weaken($self->{'associated_metaclass'});
$self->_initialize_body;
original_method => $params->{original_method},
# inherit from Class::MOP::Generated
- is_inline => ($params->{associated_metaclass}
- && $params->{associated_metaclass}->instance_metaclass->is_inlinable),
+ is_inline => $params->{associated_metaclass}->instance_metaclass->is_inlinable,
definition_context => $params->{definition_context},
# defined in this class