From 0cd2f77785298c4f0395354c87abe3183298e7e1 Mon Sep 17 00:00:00 2001 From: fukachan Date: Mon, 17 Sep 2001 11:59:23 +0000 Subject: define AUTOLOAD() to hook up md_XXX() functions XXX For example, md_XXX() should be implemented at XXX IO::Adapter::SQL::toymodel.pm --- fml/lib/IO/Adapter.pm | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'fml/lib/IO') diff --git a/fml/lib/IO/Adapter.pm b/fml/lib/IO/Adapter.pm index cea8fe81..d524866f 100644 --- a/fml/lib/IO/Adapter.pm +++ b/fml/lib/IO/Adapter.pm @@ -4,11 +4,11 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Adapter.pm,v 1.7 2001/08/26 05:52:08 fukachan Exp $ +# $FML: Adapter.pm,v 1.8 2001/09/17 11:28:31 fukachan Exp $ # package IO::Adapter; -use vars qw(@ISA @ORIG_ISA $FirstTime); +use vars qw(@ISA @ORIG_ISA $FirstTime $AUTOLOAD); use strict; use Carp; use IO::Adapter::ErrorStatus qw(error_set error error_clear); @@ -398,6 +398,10 @@ sub find } +=head2 C + +=cut + # Descriptions: destructor # request is forwarded to close() method. # Arguments: $self $args @@ -411,6 +415,33 @@ sub DESTROY } + +=head2 C + +=cut + +sub AUTOLOAD +{ + my ($self, @varargs) = @_; + + return if $AUTOLOAD =~ /DESTROY/; + + my $comname = $AUTOLOAD; + $comname =~ s/.*:://; + + # try md_something() for something() + my $fp = "md_${comname}"; + + if ($self->can($fp)) { + $self->$fp(@varargs); + } + else { + croak("${comname}() nor md_${comname}() is not found"); + croak($@); + } +} + + =head2 =item C -- cgit v1.2.1