From: gfx Date: Sun, 25 Oct 2009 06:39:51 +0000 (+0900) Subject: Use get_code_ref() X-Git-Tag: 0.40_01~19 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5124b7171ce498f9bb43befc007d9248817d6454;p=gitmo%2FMouse.git Use get_code_ref() --- diff --git a/lib/Mouse/Meta/Method/Constructor.pm b/lib/Mouse/Meta/Method/Constructor.pm index c2bcc51..c4f68fd 100644 --- a/lib/Mouse/Meta/Method/Constructor.pm +++ b/lib/Mouse/Meta/Method/Constructor.pm @@ -1,5 +1,5 @@ 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) = @_; @@ -177,10 +177,7 @@ sub _generate_BUILDALL { 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);}; } } diff --git a/lib/Mouse/Meta/Method/Destructor.pm b/lib/Mouse/Meta/Method/Destructor.pm index 61ab200..b83c71b 100644 --- a/lib/Mouse/Meta/Method/Destructor.pm +++ b/lib/Mouse/Meta/Method/Destructor.pm @@ -1,5 +1,5 @@ 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{ } @@ -12,9 +12,7 @@ sub _generate_destructor{ 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"; } } diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index 72e929b..3b08ffe 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -51,11 +51,8 @@ sub BUILDALL { 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(@_); } @@ -74,11 +71,8 @@ sub DEMOLISHALL { # 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(); }