Revert the last few commits related to deprecating alias_method, which
[gitmo/Class-MOP.git] / lib / Class / MOP / Class.pm
index c8962f2..9136f86 100644 (file)
@@ -710,9 +710,19 @@ sub add_method {
 }
 
 sub alias_method {
-    my $self = shift;
+    my ($self, $method_name, $method) = @_;
+    (defined $method_name && $method_name)
+        || confess "You must define a method name";
+
+    my $body = (blessed($method) ? $method->body : $method);
+    ('CODE' eq ref($body))
+        || confess "Your code block must be a CODE reference";
+
+    $self->add_package_symbol(
+        { sigil => '&', type => 'CODE', name => $method_name } => $body
+    );
 
-    $self->add_method(@_);
+    $self->update_package_cache_flag; # the method map will not list aliased methods
 }
 
 sub has_method {
@@ -1453,13 +1463,8 @@ Wrap a code ref (C<$attrs{body>) with C<method_metaclass>.
 
 =item B<add_method ($method_name, $method, %attrs)>
 
-This will take a C<$method_name> and CODE reference or meta method
-objectand install it into the class's package.
-
-You are strongly encouraged to pass a meta method object instead of a
-code reference. If you do so, that object gets stored as part of the
-class's method map, providing more useful information about the method
-for introspection.
+This will take a C<$method_name> and CODE reference to that
+C<$method> and install it into the class's package.
 
 B<NOTE>:
 This does absolutely nothing special to C<$method>
@@ -1467,6 +1472,16 @@ other than use B<Sub::Name> to make sure it is tagged with the
 correct name, and therefore show up correctly in stack traces and
 such.
 
+=item B<alias_method ($method_name, $method)>
+
+This will take a C<$method_name> and CODE reference to that
+C<$method> and alias the method into the class's package.
+
+B<NOTE>:
+Unlike C<add_method>, this will B<not> try to name the
+C<$method> using B<Sub::Name>, it only aliases the method in
+the class's package.
+
 =item B<has_method ($method_name)>
 
 This just provides a simple way to check if the class implements
@@ -1554,11 +1569,6 @@ This will return the first method to match a given C<$method_name> in
 the superclasses, this is basically equivalent to calling
 C<SUPER::$method_name>, but it can be dispatched at runtime.
 
-=item B<alias_method ($method_name, $method)>
-
-B<NOTE>: This method is now deprecated. Just use C<add_method>
-instead.
-
 =back
 
 =head2 Method Modifiers