# 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 by Don
-# Armstrong <don@donarmstrong.com>.
+# file README and COPYING for more information.
+# Copyright 2003,2004 by Don Armstrong <don@donarmstrong.com>.
# $Id$
package Class::Modular;
use Storable qw(dclone); # Used for deep copying objects
BEGIN{
- $VERSION = '0.1';
+ $VERSION = undef || q(SVN Development Version: ).q$Id:$;
($REVISION) = q$LastChangedRevision$ =~ /\$LastChangedRevision:\s+([^\s+])/;
$DEBUG = 0 unless defined $DEBUG;
}
# check to see if the subclass has already been loaded.
- if (not defined $self->{$cm}{_subclasses}->{$subclass}){
+ if (not defined $self->{$cm}{_subclasses}{$subclass}){
eval {
no strict 'refs';
# Yeah, I don't care if calling an inherited AUTOLOAD
&{"${subclass}::_init"}($self);
};
die $@ if $@ and $@ !~ /^Undefined function ${subclass}::_init at [^\n]*$/;
- $self->{$cm}{_subclasses}->{$subclass} = {};
+ $self->{$cm}{_subclasses}{$subclass} = {};
}
else {
carp "Not reloading subclass $subclass" if $DEBUG;
$method = $subclass.'::'.$method;
}
my ($method_name) = $method =~ /\:*([^\:]+)\s*$/;
- if (exists $self->{$cm}{_methodhash}->{$method_name}) {
- if ($self->{$cm}{_methodhash}->{$method_name}->{overridden}) {
+ if (exists $self->{$cm}{_methodhash}{$method_name}) {
+ if ($self->{$cm}{_methodhash}{$method_name}{overridden}) {
carp "Not overriding already overriden method $method_name\n" if $DEBUG;
next;
}
- carp "Overriding $method_name $self->{$cm}{_methodhash}->{$method_name}->{reference} with $method\n";
+ carp "Overriding $method_name $self->{$cm}{_methodhash}{$method_name}{reference} with $method\n";
}
- $self->{$cm}{_methodhash}->{$method_name}->{reference} = $method;
- $self->{$cm}{_methodhash}->{$method_name}->{subclass} = $subclass;
+ $self->{$cm}{_methodhash}{$method_name}{reference} = $method;
+ $self->{$cm}{_methodhash}{$method_name}{subclass} = $subclass;
}
}
sub override {
my ($self, $method_name, $function_reference) = @_;
- $self->{$cm}{_methodhash}->{$method_name}->{reference} = $function_reference;
- $self->{$cm}{_methodhash}->{$method_name}->{overridden} = 1;
+ $self->{$cm}{_methodhash}{$method_name}{reference} = $function_reference;
+ $self->{$cm}{_methodhash}{$method_name}{overridden} = 1;
}
=head2 clone
if (ref $self and exists $self->{$cm}{_methodhash}->{$method}) {
# If the method is defined, return a reference to the
# method.
- return $self->{$cm}{_methodhash}->{$method}->{reference};
+ return $self->{$cm}{_methodhash}{$method}{reference};
}
else {
# Otherwise, let UNIVERSAL::can deal with the method
$method_name =~ s/.*\://;
- if (exists $self->{$cm}{_methodhash}->{$method_name}) {
- return $self->{$cm}{_methodhash}->{$method_name}->{subclass};
+ if (exists $self->{$cm}{_methodhash}{$method_name}) {
+ return $self->{$cm}{_methodhash}{$method_name}{subclass};
}
return undef;
}
return;
}
- if (exists $self->{$cm}{_methodhash}->{$method} and
- defined $self->{$cm}{_methodhash}->{$method}->{reference}) {
+ if (exists $self->{$cm}{_methodhash}{$method} and
+ defined $self->{$cm}{_methodhash}{$method}{reference}) {
eval {
no strict 'refs';
goto &{$self->{$cm}{_methodhash}{$method}{reference}};
}
}
-
1;
__END__
+=head1 BUGS
+
+Because this module works through AUTOLOAD, utilities that use
+can($object) instead of $object->can() will fail to see routines that
+are actually there. Params::Validate, an excellent module, is one of
+these offenders.
+
+=head1 COPYRIGHT
+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>
+
+=cut