sub _make_delegation_method {
my($self, $handle, $method_to_call) = @_;
- my $delegator = $self->delegation_metaclass;
- Mouse::Util::load_class($delegator);
-
- return $delegator->_generate_delegation($self, $handle, $method_to_call);
+ return Mouse::Util::load_class($self->delegation_metaclass)
+ ->_generate_delegation($self, $handle, $method_to_call);
}
sub throw_error{
$self->{strict_constructor} = $args{strict_constructor};
if ($args{inline_constructor}) {
- my $c = $self->constructor_class;
- Mouse::Util::load_class($c);
$self->add_method($args{constructor_name} =>
- $c->_generate_constructor($self, \%args));
+ Mouse::Util::load_class($self->constructor_class)
+ ->_generate_constructor($self, \%args));
}
if ($args{inline_destructor}) {
- my $c = $self->destructor_class;
- Mouse::Util::load_class($c);
$self->add_method(DESTROY =>
- $c->_generate_destructor($self, \%args));
+ Mouse::Util::load_class($self->destructor_class)
+ ->_generate_destructor($self, \%args));
}
# Moose's make_immutable returns true allowing calling code to skip setting an explicit true value
package Mouse::Meta::Module;
-use Mouse::Util qw/:meta get_code_package get_code_ref load_class not_supported/; # enables strict and warnings
+use Mouse::Util qw/:meta get_code_package get_code_ref not_supported/; # enables strict and warnings
use Carp ();
use Scalar::Util ();
my($self, $method_name) = @_;
if(my $code = $self->get_method_body($method_name)){
- my $method_metaclass = $self->method_metaclass;
- load_class($method_metaclass);
-
- return $method_metaclass->wrap(
+ return Mouse::Util::load_class($self->method_metaclass)->wrap(
body => $code,
name => $method_name,
package => $self->name,
return undef if $is_class_loaded_cache{$class} ||= is_class_loaded($class);
- my $file = $class . '.pm';
- $file =~ s{::}{/}g;
+ $class =~ s{::}{/}g;
+ $class .= '.pm';
return do {
local $@;
- eval { require($file) };
+ eval { require $class };
$@;
};
}
my $e = _try_load_one_class($class);
Carp::confess "Could not load class ($class) because : $e" if $e;
- return 1;
+ return $class;
}
sub is_class_loaded;