package Mouse::Meta::Method::Constructor;
-use Mouse::Util; # enables strict and warnings
+use Mouse::Util qw(get_code_ref); # enables strict and warnings
sub _inline_slot{
my(undef, $self_var, $attr_name) = @_;
my @code;
for my $class ($metaclass->linearized_isa) {
- no strict 'refs';
- no warnings 'once';
-
- if (*{ $class . '::BUILD' }{CODE}) {
+ if (get_code_ref($class, 'BUILD')) {
unshift @code, qq{${class}::BUILD(\$instance, \$args);};
}
}
package Mouse::Meta::Method::Destructor;
-use Mouse::Util; # enables strict and warnings
+use Mouse::Util qw(get_code_ref); # enables strict and warnings
sub _empty_DESTROY{ }
my $demolishall = '';
for my $class ($metaclass->linearized_isa) {
- no strict 'refs';
- no warnings 'once';
- if (*{$class . '::DEMOLISH'}{CODE}) {
+ if (get_code_ref($class, 'DEMOLISH')) {
$demolishall .= "${class}::DEMOLISH(\$self);\n";
}
}
return unless $self->can('BUILD');
for my $class (reverse $self->meta->linearized_isa) {
- my $build = do{
- no strict 'refs';
- no warnings 'once';
- *{ $class . '::BUILD' }{CODE};
- } or next;
+ my $build = Mouse::Util::get_code_ref($class, 'BUILD')
+ || next;
$self->$build(@_);
}
# that time (at least tests suggest so ;)
foreach my $class (@{ Mouse::Util::get_linear_isa(ref $self) }) {
- my $demolish = do{
- no strict 'refs';
- no warnings 'once';
- *{ $class . '::DEMOLISH'}{CODE};
- } or next;
+ my $demolish = Mouse::Util::get_code_ref($class, 'DEMOLISH')
+ || next;
$self->$demolish();
}