# 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;
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;
}
}
+=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
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 {
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