Bump to 0.56
[gitmo/Moose.git] / lib / Moose / Meta / Role.pm
index 1d0d8bc..640cb84 100644 (file)
@@ -6,9 +6,9 @@ use warnings;
 use metaclass;
 
 use Carp         'confess';
-use Scalar::Util 'blessed', 'reftype';
+use Scalar::Util 'blessed';
 
-our $VERSION   = '0.13';
+our $VERSION   = '0.56';
 our $AUTHORITY = 'cpan:STEVAN';
 
 use Moose::Meta::Class;
@@ -290,9 +290,10 @@ sub get_method_map {
     my $role_name        = $self->name;
     my $method_metaclass = $self->method_metaclass;
 
-    foreach my $symbol ($self->list_all_package_symbols('CODE')) {
+    my %all_code = $self->get_all_package_symbols('CODE');
 
-        my $code = $self->get_package_symbol('&' . $symbol);
+    foreach my $symbol (keys %all_code) {
+        my $code = $all_code{$symbol};
 
         my ($pkg, $name) = Class::MOP::get_code_info($code);
 
@@ -310,8 +311,17 @@ sub get_method_map {
             next unless $self->does_role($role);
         }
         else {
-            next if ($pkg  || '') ne $role_name ||
-                    (($name || '') ne '__ANON__' && ($pkg  || '') ne $role_name);
+            # NOTE:
+            # in 5.10 constant.pm the constants show up 
+            # as being in the right package, but in pre-5.10
+            # they show up as constant::__ANON__ so we 
+            # make an exception here to be sure that things
+            # work as expected in both.
+            # - SL
+            unless ($pkg eq 'constant' && $name eq '__ANON__') {
+                next if ($pkg  || '') ne $role_name ||
+                        (($name || '') ne '__ANON__' && ($pkg  || '') ne $role_name);
+            }            
         }
         
         $map->{$symbol} = $method_metaclass->wrap(
@@ -347,10 +357,13 @@ sub alias_method {
         || confess "You must define a method name";
 
     my $body = (blessed($method) ? $method->body : $method);
-    ('CODE' eq (reftype($body) || ''))
+    ('CODE' eq ref($body))
         || confess "Your code block must be a CODE reference";
 
-    $self->add_package_symbol("&${method_name}" => $body);
+    $self->add_package_symbol(
+        { sigil => '&', type => 'CODE', name => $method_name },
+        $body
+    );
 }
 
 ## ------------------------------------------------------------------