bump version to 0.75_01
[gitmo/Moose.git] / lib / Moose / Meta / Role.pm
index 997389a..9c00815 100644 (file)
@@ -8,7 +8,7 @@ use metaclass;
 use Scalar::Util 'blessed';
 use Carp         'confess';
 
-our $VERSION   = '0.72_01';
+our $VERSION   = '0.75_01';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -117,6 +117,12 @@ foreach my $action (
     }) if exists $methods->{remove};
 }
 
+$META->add_attribute(
+    'method_metaclass',
+    reader  => 'method_metaclass',
+    default => 'Moose::Meta::Role::Method',
+);
+
 ## some things don't always fit, so they go here ...
 
 sub add_attribute {
@@ -136,15 +142,6 @@ sub add_attribute {
     $self->get_attribute_map->{$name} = $attr_desc;
 }
 
-# DEPRECATED 
-# sub _clean_up_required_methods {
-#     my $self = shift;
-#     foreach my $method ($self->get_required_method_list) {
-#         $self->remove_required_methods($method)
-#             if $self->has_method($method);
-#     }
-# }
-
 ## ------------------------------------------------------------------
 ## method modifiers
 
@@ -256,7 +253,7 @@ sub update_package_cache_flag {
 ## ------------------------------------------------------------------
 ## subroles
 
-__PACKAGE__->meta->add_attribute('roles' => (
+$META->add_attribute('roles' => (
     reader  => 'get_roles',
     default => sub { [] }
 ));
@@ -295,8 +292,6 @@ sub does_role {
 ## ------------------------------------------------------------------
 ## methods
 
-sub method_metaclass { 'Moose::Meta::Role::Method' }
-
 sub get_method_map {
     my $self = shift;
 
@@ -323,18 +318,10 @@ sub get_method_map {
                         $map->{$symbol}->body == $code;
 
         my ($pkg, $name) = Class::MOP::get_code_info($code);
+        my $meta = Class::MOP::class_of($pkg);
 
-        if ($pkg->can('meta')
-            # NOTE:
-            # we don't know what ->meta we are calling
-            # here, so we need to be careful cause it
-            # just might blow up at us, or just complain
-            # loudly (in the case of Curses.pm) so we
-            # just be a little overly cautious here.
-            # - SL
-            && eval { no warnings; blessed($pkg->meta) } # FIXME calls meta
-            && $pkg->meta->isa('Moose::Meta::Role')) {
-            my $role = $pkg->meta->name;
+        if ($meta && $meta->isa('Moose::Meta::Role')) {
+            my $role = $meta->name;
             next unless $self->does_role($role);
         }
         else {
@@ -426,6 +413,8 @@ sub get_method_list {
 }
 
 sub alias_method {
+    Carp::cluck("The alias_method method is deprecated. Use add_method instead.\n");
+
     my $self = shift;
 
     $self->add_method(@_);
@@ -464,7 +453,7 @@ sub combine {
     my (@roles, %role_params);
     while (@role_specs) {
         my ($role, $params) = @{ splice @role_specs, 0, 1 };
-        push @roles => $role->meta;
+        push @roles => Class::MOP::class_of($role);
         next unless defined $params;
         $role_params{$role} = $params; 
     }
@@ -782,6 +771,10 @@ L<Moose::Meta::Role>, object, a L<Moose::Meta::Class> object, or a
 The options are passed directly to the constructor for the appropriate
 L<Moose::Meta::Role::Application> subclass.
 
+Note that this will apply the role even if the C<$thing> in question already
+C<does> this role.  L<Moose::Util/does_role> is a convenient wrapper for
+finding out if role application is necessary.
+
 =back
 
 =head2 Roles and other roles