Checking in changes prior to tagging of version 0.72.
[gitmo/Mouse.git] / lib / Mouse / Role.pm
index 56b90b7..fb34367 100644 (file)
@@ -1,7 +1,7 @@
 package Mouse::Role;
 use Mouse::Exporter; # enables strict and warnings
 
-our $VERSION = '0.40_08';
+our $VERSION = '0.72';
 
 use Carp         qw(confess);
 use Scalar::Util qw(blessed);
@@ -30,9 +30,8 @@ sub extends  {
     Carp::croak "Roles do not support 'extends'";
 }
 
-sub with     {
-    my $meta = Mouse::Meta::Role->initialize(scalar caller);
-    Mouse::Util::apply_all_roles($meta->name, @_);
+sub with {
+    Mouse::Util::apply_all_roles(scalar(caller), @_);
     return;
 }
 
@@ -43,43 +42,35 @@ sub has {
     $meta->throw_error(q{Usage: has 'name' => ( key => value, ... )})
         if @_ % 2; # odd number of arguments
 
-    if(ref $name){ # has [qw(foo bar)] => (...)
-        for (@{$name}){
-            $meta->add_attribute($_ => @_);
-        }
-    }
-    else{ # has foo => (...)
-        $meta->add_attribute($_ => @_);
+    for my $n(ref($name) ? @{$name} : $name){
+        $meta->add_attribute($n => @_);
     }
     return;
 }
 
 sub before {
     my $meta = Mouse::Meta::Role->initialize(scalar caller);
-
     my $code = pop;
-    for (@_) {
-        $meta->add_before_method_modifier($_ => $code);
+    for my $name($meta->_collect_methods(@_)) {
+        $meta->add_before_method_modifier($name => $code);
     }
     return;
 }
 
 sub after {
     my $meta = Mouse::Meta::Role->initialize(scalar caller);
-
     my $code = pop;
-    for (@_) {
-        $meta->add_after_method_modifier($_ => $code);
+    for my $name($meta->_collect_methods(@_)) {
+        $meta->add_after_method_modifier($name => $code);
     }
     return;
 }
 
 sub around {
     my $meta = Mouse::Meta::Role->initialize(scalar caller);
-
     my $code = pop;
-    for (@_) {
-        $meta->add_around_method_modifier($_ => $code);
+    for my $name($meta->_collect_methods(@_)) {
+        $meta->add_around_method_modifier($name => $code);
     }
     return;
 }
@@ -148,7 +139,7 @@ Mouse::Role - The Mouse Role
 
 =head1 VERSION
 
-This document describes Mouse version 0.40_08
+This document describes Mouse version 0.72
 
 =head1 SYNOPSIS
 
@@ -161,20 +152,17 @@ This document describes Mouse version 0.40_08
 
 Returns this role's metaclass instance.
 
-=head2 C<< before (method|methods) -> CodeRef >>
+=head2 C<< before (method|methods|regexp) -> CodeRef >>
 
-Sets up a B<before> method modifier. See L<Moose/before> or
-L<Class::Method::Modifiers/before>.
+Sets up a B<before> method modifier. See L<Moose/before>.
 
-=head2 C<< after (method|methods) => CodeRef >>
+=head2 C<< after (method|methods|regexp) => CodeRef >>
 
-Sets up an B<after> method modifier. See L<Moose/after> or
-L<Class::Method::Modifiers/after>.
+Sets up an B<after> method modifier. See L<Moose/after>.
 
-=head2 C<< around (method|methods) => CodeRef >>
+=head2 C<< around (method|methods|regexp) => CodeRef >>
 
-Sets up an B<around> method modifier. See L<Moose/around> or
-L<Class::Method::Modifiers/around>.
+Sets up an B<around> method modifier. See L<Moose/around>.
 
 =head2 C<super>