]> git.donarmstrong.com Git - class_modular.git/.git/commitdiff
* Add isa routine
authorDon Armstrong <don@donarmstrong.com>
Sat, 22 Jan 2005 21:25:46 +0000 (21:25 +0000)
committerDon Armstrong <don@donarmstrong.com>
Sat, 22 Jan 2005 21:25:46 +0000 (21:25 +0000)
git-svn-id: file:///srv/don_svn/class_modular/trunk@39 96c6a18b-02ce-0310-9fca-9eb62c757ba6

lib/Class/Modular.pm

index 7835b1224fd1731f764c28ccc9964181a61815a2..a02c7e96ddf88093316de0c46df7c786cb6a08e7 100644 (file)
@@ -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.04SVN$;
      ($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