copyright date changes on Class::MOP
[gitmo/Class-MOP.git] / examples / C3MethodDispatchOrder.pod
index a45e593..f6156d5 100644 (file)
@@ -8,11 +8,11 @@ use warnings;
 use Carp 'confess';
 use Algorithm::C3;
 
-our $VERSION = '0.02';
+our $VERSION = '0.03';
 
 use base 'Class::MOP::Class';
 
-my $_find_method_in_superclass = sub {
+my $_find_method = sub {
     my ($class, $method) = @_;
     foreach my $super ($class->class_precedence_list) {
         return $super->meta->get_method($method)   
@@ -31,24 +31,27 @@ C3MethodDispatchOrder->meta->add_around_method_modifier('initialize' => sub {
             my $label = ${$meta->name . '::AUTOLOAD'};
             $method_name = (split /\:\:/ => $label)[-1];
         }
-        my $method = $_find_method_in_superclass->($meta, $method_name);
+        my $method = $_find_method->($meta, $method_name);
         (defined $method) || confess "Method ($method_name) not found";
         goto &$method;
-    });
+    }) unless $meta->has_method('AUTOLOAD');
     $meta->add_method('can' => sub {
-        $_find_method_in_superclass->($_[0]->meta, $_[1]);
-    });
+        $_find_method->($_[0]->meta, $_[1]);
+    }) unless $meta->has_method('can');   
        return $meta;
 });
 
 sub superclasses {
     my $self = shift;
-    no strict 'refs';
+    
+    $self->add_package_symbol('@SUPERS' => [])    
+        unless $self->has_package_symbol('@SUPERS');
+            
     if (@_) {
         my @supers = @_;
-        @{$self->get_package_variable('@SUPERS')} = @supers;
+        @{$self->get_package_symbol('@SUPERS')} = @supers;
     }
-    @{$self->get_package_variable('@SUPERS')};        
+    @{$self->get_package_symbol('@SUPERS')};        
 }
 
 sub class_precedence_list {
@@ -118,13 +121,15 @@ This example could be used as a template for other method dispatch orders
 as well, all that is required is to write a the C<class_precedence_list> method 
 which will return a linearized list of classes to dispatch along. 
 
-=head1 AUTHOR
+=head1 AUTHORS
 
 Stevan Little E<lt>stevan@iinteractive.comE<gt>
 
+Yuval Kogman E<lt>nothingmuch@woobling.comE<gt>
+
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2006 by Infinity Interactive, Inc.
+Copyright 2006-2008 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>