|
Hi,
I'm trying to sub class Data::Table and override the colIndex function to ignore case. I'd like to use an InsideOut object, but it seems to get chopped when invoking parent methods. Here is a script that shows the problem. MyChild::inner_call never gets invoked. Am I doing something wrong?
Thanks, J
#!/usr/bin/env perl
use warnings;
use strict;
use Carp;
#use Smart::Comments;
# old style hash based perl object
package MyParent;
require Exporter;
require AutoLoader;
use vars qw(@ISA);
@ISA = qw(Exporter AutoLoader);
{
sub new {
my ($pkg, $d) = @_;
my $class = ref($pkg) || $pkg;
my $self = {data => $d};
return bless $self, $class;
}
sub inner_call {
my ($self) = @_;
#print "MyParent::inner_call\n";
return $self->{data};
}
sub parent_call {
my ($self) = @_;
#print "MyParent::parent_call\n";
### $self: "$self"
return $self->inner_call();
}
}
# new style InsideOut object
package MyChild;
use Object::InsideOut qw(MyParent);
{
sub init :Init {
my ($self, $args) = @_;
my $parent = MyParent->new($args->{base});
$self->inherit($parent);
}
sub inner_call {
my ($self) = @_;
#print "MyChild::inner_call\n";
return $self->heritage('MyParent')->inner_call() . " MyChild";
}
sub child_call {
my ($self) = @_;
#print "MyChild::child_call\n";
### $self: "$self"
return $self->parent_call();
}
}
package main;
my $obj = MyChild->new( base => "MyParent" );
print " child: " . $obj->child_call() . "\n";
print "parent: " . $obj->parent_call() . "\n";
exit(0);
|