fallback => 1,
;
-sub new{
- my($class, %args) = @_;
+sub wrap{
+ my $class = shift;
- return bless \%args, $class;
+ return $class->_new(@_);
}
-sub body { $_[0]->{body} }
-sub name { $_[0]->{name} }
-sub package_name{ $_[0]->{package} }
+sub _new{
+ my $class = shift;
+ return $class->meta->new_object(@_)
+ if $class ne __PACKAGE__;
+
+ return bless {@_}, $class;
+}
+
+sub body { $_[0]->{body} }
+sub name { $_[0]->{name} }
+sub package_name { $_[0]->{package} }
+sub associated_metaclass { $_[0]->{associated_metaclass} }
sub fully_qualified_name {
my $self = shift;
}
1;
-
__END__
=head1 NAME
load_class($method_metaclass);
my $package = $self->name;
- return $method_metaclass->new(
- body => $package->can($method_name),
- name => $method_name,
- package => $package,
+ return $method_metaclass->wrap(
+ body => $package->can($method_name),
+ name => $method_name,
+ package => $package,
+ associated_metaclass => $self,
);
}
use Mouse::Meta::Method;
our @ISA = qw(Mouse::Meta::Method);
+sub _new {
+ my $class = shift;
+ return $class->meta->new_object(@_)
+ if $class ne __PACKAGE__;
+ return bless {@_}, $class;
+}
+
1;
__END__