]> git.donarmstrong.com Git - class_modular.git/.git/blobdiff - lib/Class/Modular.pm
* Remove useless -> from Class::Modular
[class_modular.git/.git] / lib / Class / Modular.pm
index 9197583de709999106d6cdc0d5233ed263530492..95921ce2dfcf89b5e808d08c70fd23830fef07cb 100644 (file)
@@ -1,7 +1,7 @@
 # This module is part of DA, Don Armstrong's Modules, and is released
 # under the terms of the GPL version 2, or any later version. See the
-# file README and COPYING for more information. Copyright 2003 by Don
-# Armstrong <don@donarmstrong.com>.
+# file README and COPYING for more information.
+# Copyright 2003,2004 by Don Armstrong <don@donarmstrong.com>.
 # $Id$
 
 package Class::Modular;
@@ -48,7 +48,7 @@ use Carp;
 use Storable qw(dclone); # Used for deep copying objects
 
 BEGIN{
-     $VERSION = '0.1';
+     $VERSION = undef || q(SVN Development Version: ).q$Id:$;
      ($REVISION) = q$LastChangedRevision$ =~ /\$LastChangedRevision:\s+([^\s+])/;
      $DEBUG = 0 unless defined $DEBUG;
 }
@@ -149,7 +149,7 @@ sub load($$;$) {
 
      # check to see if the subclass has already been loaded.
 
-     if (not defined $self->{$cm}{_subclasses}->{$subclass}){
+     if (not defined $self->{$cm}{_subclasses}{$subclass}){
          eval {
               no strict 'refs';
               # Yeah, I don't care if calling an inherited AUTOLOAD
@@ -160,7 +160,7 @@ sub load($$;$) {
               &{"${subclass}::_init"}($self);
          };
          die $@ if $@ and $@ !~ /^Undefined function ${subclass}::_init at [^\n]*$/;
-         $self->{$cm}{_subclasses}->{$subclass} = {};
+         $self->{$cm}{_subclasses}{$subclass} = {};
      }
      else {
          carp "Not reloading subclass $subclass" if $DEBUG;
@@ -194,15 +194,15 @@ sub _addmethods($@) {
               $method = $subclass.'::'.$method;
          }
          my ($method_name) = $method =~ /\:*([^\:]+)\s*$/;
-         if (exists $self->{$cm}{_methodhash}->{$method_name}) {
-              if ($self->{$cm}{_methodhash}->{$method_name}->{overridden}) {
+         if (exists $self->{$cm}{_methodhash}{$method_name}) {
+              if ($self->{$cm}{_methodhash}{$method_name}{overridden}) {
                    carp "Not overriding already overriden method $method_name\n" if $DEBUG;
                    next;
               }
-              carp "Overriding $method_name $self->{$cm}{_methodhash}->{$method_name}->{reference} with $method\n";
+              carp "Overriding $method_name $self->{$cm}{_methodhash}{$method_name}{reference} with $method\n";
          }
-         $self->{$cm}{_methodhash}->{$method_name}->{reference} = $method;
-         $self->{$cm}{_methodhash}->{$method_name}->{subclass} = $subclass;
+         $self->{$cm}{_methodhash}{$method_name}{reference} = $method;
+         $self->{$cm}{_methodhash}{$method_name}{subclass} = $subclass;
      }
 
 }
@@ -234,8 +234,8 @@ may need to be changed.
 sub override {
      my ($self, $method_name, $function_reference) = @_;
 
-     $self->{$cm}{_methodhash}->{$method_name}->{reference} = $function_reference;
-     $self->{$cm}{_methodhash}->{$method_name}->{overridden} = 1;
+     $self->{$cm}{_methodhash}{$method_name}{reference} = $function_reference;
+     $self->{$cm}{_methodhash}{$method_name}{overridden} = 1;
 }
 
 =head2 clone
@@ -320,7 +320,7 @@ sub can{
      if (ref $self and exists $self->{$cm}{_methodhash}->{$method}) {
          # If the method is defined, return a reference to the
          # method.
-         return $self->{$cm}{_methodhash}->{$method}->{reference};
+         return $self->{$cm}{_methodhash}{$method}{reference};
      }
      else {
          # Otherwise, let UNIVERSAL::can deal with the method
@@ -355,8 +355,8 @@ sub handledby{
 
      $method_name =~ s/.*\://;
 
-     if (exists $self->{$cm}{_methodhash}->{$method_name}) {
-         return $self->{$cm}{_methodhash}->{$method_name}->{subclass};
+     if (exists $self->{$cm}{_methodhash}{$method_name}) {
+         return $self->{$cm}{_methodhash}{$method_name}{subclass};
      }
      return undef;
 }
@@ -425,8 +425,8 @@ sub AUTOLOAD{
         return;
      }
 
-     if (exists $self->{$cm}{_methodhash}->{$method} and
-        defined $self->{$cm}{_methodhash}->{$method}->{reference}) {
+     if (exists $self->{$cm}{_methodhash}{$method} and
+        defined $self->{$cm}{_methodhash}{$method}{reference}) {
          eval {
               no strict 'refs';
               goto &{$self->{$cm}{_methodhash}{$method}{reference}};
@@ -437,13 +437,27 @@ sub AUTOLOAD{
      }
 }
 
-
 1;
 
 
 __END__
 
+=head1 BUGS
+
+Because this module works through AUTOLOAD, utilities that use
+can($object) instead of $object->can() will fail to see routines that
+are actually there. Params::Validate, an excellent module, is one of
+these offenders.
+
+=head1 COPYRIGHT
 
+This module is part of DA, Don Armstrong's Modules, and is released
+under the terms of the GPL version 2, or any later version. See the
+file README and COPYING for more information.
+
+Copyright 2003, 2004 by Don Armstrong <don@donarmstrong.com>
+
+=cut