]> git.donarmstrong.com Git - class_modular.git/.git/blobdiff - lib/Class/Modular.pm
start 0.06SVN version
[class_modular.git/.git] / lib / Class / Modular.pm
index 7835b1224fd1731f764c28ccc9964181a61815a2..ec58bb485837789ca50dbfc0c0b895df83c098ba 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,2004 by Don Armstrong <don@donarmstrong.com>.
+# Copyright 2003,2005 by Don Armstrong <don@donarmstrong.com>.
 # $Id$
 
 package Class::Modular;
@@ -72,7 +72,7 @@ use Storable qw(dclone); # Used for deep copying objects
 use Safe; # Use Safe when we are dealing with coderefs
 
 BEGIN{
-     $VERSION = q$0.03SVN$;
+     $VERSION = q$0.06SVN$;
      ($REVISION) = q$LastChangedRevision$ =~ /\$LastChangedRevision:\s+([^\s+])/;
      $DEBUG = 0 unless defined $DEBUG;
      $USE_SAFE = 1 unless defined $USE_SAFE;
@@ -304,6 +304,26 @@ sub can{
      }
 }
 
+=head2 isa
+
+     $obj->isa('TYPE');
+     Class::Modular->isa('TYPE');
+
+Replaces UNIVERSAL's isa method with one that knows which modules have
+been loaded into this object. Calls C<is_loaded> with the type passed,
+then calls UNIVERSAL::isa if the type isn't loaded.
+
+=cut
+
+sub isa{
+     my ($self,$type) = @_;
+
+     croak "Usage: isa(object-ref, type);\n" if not defined $type;
+
+     return $self->is_loaded($type) || UNIVERSAL::isa($self,$type);
+}
+
+
 
 =head2 handledby
 
@@ -445,9 +465,9 @@ sub AUTOLOAD{
 
      if (exists $self->{$cm}{_methodhash}{$method} and
         defined $self->{$cm}{_methodhash}{$method}{reference}) {
-         eval {
-              no strict 'refs';
-              goto &{$self->{$cm}{_methodhash}{$method}{reference}};
+         {
+             my $method = \&{$self->{$cm}{_methodhash}{$method}{reference}};
+             goto &$method;
          }
      }
      else {
@@ -535,7 +555,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, 2004 by Don Armstrong <don@donarmstrong.com>
+Copyright 2003, 2005 by Don Armstrong <don@donarmstrong.com>
 
 =cut