From: Don Armstrong Date: Sat, 22 Jan 2005 21:25:46 +0000 (+0000) Subject: * Add isa routine X-Git-Url: https://git.donarmstrong.com/?p=class_modular.git%2F.git;a=commitdiff_plain;h=576b9dfe2afc8ebed49d2b62fa7043ca740f33f0 * Add isa routine git-svn-id: file:///srv/don_svn/class_modular/trunk@39 96c6a18b-02ce-0310-9fca-9eb62c757ba6 --- diff --git a/lib/Class/Modular.pm b/lib/Class/Modular.pm index 7835b12..a02c7e9 100644 --- a/lib/Class/Modular.pm +++ b/lib/Class/Modular.pm @@ -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 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