# 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>.
-# $Id: Modular.pm,v 1.4 2003/10/24 04:48:51 don Exp $
+# $Id: Modular.pm,v 1.5 2003/10/25 02:15:04 don Exp $
package Class::Modular;
=back
-=head1 BUGS
-
-None known.
+=head1 FUNCTIONS
=cut
use Data::Copy qw(deep_copy); # Used for deep copying objects
BEGIN{
- ($VERSION) = q$Revision: 1.4 $ =~ /\$Revision:\s+([^\s+])/;
+ ($VERSION) = q$Revision: 1.5 $ =~ /\$Revision:\s+([^\s+])/;
$DEBUG = 0 unless defined $DEBUG;
}
# Ignore no such function errors, but trap other types of
# errors.
+ # XXX Switch to can instead.
eval {
no strict 'refs';
&$subclass::_clone($self,$clone);
}
}
+=head2 can
+
+=head3 Usage
+
+ $obj->can('METHOD');
+ Class::Modular->can('METHOD');
+
+=head3 Function
+
+Replaces UNIVERSAL's can method so that handled methods are reported
+correctly. Calls UNIVERSAL::can in the places where
+
+=head3 Returns
+
+A coderef to the method if the method is supported, undef otherwise.
+
+=head3 Args
+
+Scalar Method Name
+
+=cut
+
+sub can{
+ my ($self,$method,$vars) = @_;
+
+ if (ref $self and exists $self->{_methodhash}->{$method}) {
+ # If the method is defined, return a reference to the
+ # method.
+ return $self->{_methodhash}->{$method}->{reference};
+ }
+ else {
+ # Otherwise, let UNIVERSAL::can deal with the method
+ # appropriately.
+ return UNIVERSAL::can($self,$method);
+ }
+}
+
=head2 DESTROY
Returns : N/A
Args : N/A
- The AUTOLOAD function is responsible for calling child methods which
- have been installed into the current Class::Modular handle.
+The AUTOLOAD function is responsible for calling child methods which
+have been installed into the current Class::Modular handle.
+
+Subclasses that have a new function as well as an AUTOLOAD function
+must call Class::Modular::AUTOLOAD and set $Class::Modular::AUTOLOAD
+
+ $Class::Modular::AUTOLOAD = $AUTOLOAD;
+ goto &Class::Modular::AUTOLOAD;
=cut