Version 0.40_01
[gitmo/Mouse.git] / lib / Mouse / Meta / Module.pm
index 9f2c7f8..132e4af 100755 (executable)
@@ -1,5 +1,5 @@
 package Mouse::Meta::Module;
-use Mouse::Util qw/:meta get_code_package load_class not_supported/; # enables strict and warnings
+use Mouse::Util qw/:meta get_code_package get_code_ref load_class not_supported/; # enables strict and warnings
 
 use Carp ();
 use Scalar::Util qw/blessed weaken/;
@@ -38,9 +38,10 @@ sub get_metaclass_by_name       { $METAS{$_[0]}         }
 #sub does_metaclass_exist        { defined $METAS{$_[0]} }
 #sub remove_metaclass_by_name    { delete $METAS{$_[0]}  }
 
-
 sub name;
 
+sub namespace;
+
 # The followings are Class::MOP specific methods
 
 #sub version   { no strict 'refs'; ${shift->name.'::VERSION'}   }
@@ -66,12 +67,6 @@ sub get_attribute     {        $_[0]->{attributes}->{$_[1]} }
 sub get_attribute_list{ keys %{$_[0]->{attributes}}         }
 sub remove_attribute  { delete $_[0]->{attributes}->{$_[1]} }
 
-sub namespace{
-    my $name = $_[0]->{package};
-    no strict 'refs';
-    return \%{ $name . '::' };
-}
-
 sub add_method {
     my($self, $name, $code) = @_;
 
@@ -115,11 +110,7 @@ sub has_method {
 
     return 1 if $self->{methods}{$method_name};
 
-    my $code = do{
-        no strict 'refs';
-        no warnings 'once';
-        *{ $self->{package} . '::' . $method_name }{CODE};
-    };
+    my $code = get_code_ref($self->{package}, $method_name);
 
     return $code && $self->_code_is_mine($code);
 }
@@ -131,12 +122,7 @@ sub get_method_body{
         or $self->throw_error('You must define a method name');
 
     return $self->{methods}{$method_name} ||= do{
-        my $code = do{
-            no strict 'refs';
-            no warnings 'once';
-            *{$self->{package} . '::' . $method_name}{CODE};
-        };
-
+        my $code = get_code_ref($self->{package}, $method_name);
         ($code && $self->_code_is_mine($code)) ? $code : undef;
     };
 }
@@ -325,7 +311,7 @@ Mouse::Meta::Module - The base class for Mouse::Meta::Class and Mouse::Meta::Rol
 
 =head1 VERSION
 
-This document describes Mouse version 0.40
+This document describes Mouse version 0.40_01
 
 =head1 SEE ALSO