Subject: | Sub-class inheritance doesn't seem to work properly |
Hello,
It seems that sub-class inheritance in Object::InsideOut doesn't seem
to work properly when compared to the "use base" pragma. A simple
example:
# Base Class
# located in lib/DB.pm
package DB; {
use Object::InsideOut;
my @drivers :Field('Standard' => 'driver');
}
1;
# Sub Class
# located in lib/My/DB.pm
package My::DB; {
use Object::InsideOut qw(DB);
my @names :Field('Standard' => 'name');
}
1;
# application code, test.pl
# located just above lib directory
#!/usr/bin/perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/lib";
use My::DB;
my $db = My::DB->new();
$db->set_driver('MySQL');
################
Now when I run the program:
[user@server ~]$ ./test.pl
OIO::Method error: Can't locate object method "set_driver" via
package "My::DB"
Package: Object::InsideOut
File: /usr/lib/perl5/site_perl/5.8.5/Object/InsideOut/Autoload.pm
Line: 153
Trace begun
at /usr/lib/perl5/site_perl/5.8.5/Object/InsideOut/Autoload.pm line 153
Object::InsideOut::__ANON__('My::DB=SCALAR(0x70bf00)', 'MySQL') called
at test.pl line 11
Why doesn't this work? I think I have the reason. There happens to
be another completely unrelated package of the same name DB.pm in my
@INC located at /usr/lib/perl5/5.8.5/DB.pm and Object::InsideOut is
for some reason using this as the parent class of My::DB.
Object::InsideOut's replacement for "use base" doesn't seem to be
working properly because it is not paying attention to the specific
@INC order I have specified by doing "use lib" in my application
code. The "use base" pragma does locate the correct DB.pm parent
class at lib/DB.pm.