Hi!
I'm trying to create a new class based in a class that use Object::InsideOut. But the new class can't use the Object::InsideOut.
In the child class I do:
sub new {
my ($class,%args) = @_;
my $new_object = $class->SUPER::new(%args);
....
but, apparently, the
new of the base class it's never called.
What I'm missing?
many thanks
execution and code ...
$ perl t2.pl
I'm in the child_class new
my super is class_insideout
id: 1
Use of uninitialized value in array element at /home/glide/develop/per
+l_tests/Object_InsideOut/class_insideout.pm line 27.
Use of uninitialized value in concatenation (.) or string at /home/gli
+de/develop/perl_tests/Object_InsideOut/class_insideout.pm line 27.
name:
Use of uninitialized value in array element at /home/glide/develop/per
+l_tests/Object_InsideOut/class_insideout.pm line 28.
Use of uninitialized value in concatenation (.) or string at /home/gli
+de/develop/perl_tests/Object_InsideOut/class_insideout.pm line 28.
address:
base class code
package class_insideout;
use strict;
use warnings;
{
use Object::InsideOut;
my @name
:Field
:Arg(Name => 'name', 'Mandatory' => 1)
:Std(Name => 'name');
my @address
:Field
:Arg(Name => 'address', 'Mandatory' => 1)
:Std(Name => 'address');
sub _init :Init{
my ($self,$args) = @_;
warn("I'm in the ".__PACKAGE__ ." _init\n");
return;
}
sub write {
my ($self) = @_;
print "name: ". $name[$$self] ."\n";
print "address: ". $address[$$self] ."\n";
}
}
1;
child class code
package child_class;
use strict;
use warnings;
use Class::Std::Utils;
use base qw(class_insideout);
{
my %num_ID;
sub new {
my ($class, %args) = @_;
my $new_object = $class->SUPER::new(%args);
warn("I'm in the ".__PACKAGE__." new\n");
warn("my super is @child_class::ISA \n");
$num_ID{ident $new_object} = $args{id};
return $new_object;
}
sub write {
my ($self) = @_;
print "id: ". $num_ID{ident $self} ."\n";
$self->SUPER::write();
return;
}
}
1;
script code
use strict;
use warnings;
use FindBin;
use lib $FindBin::Bin;
use child_class;
my $person = child_class->new(id=>1,name=>'aaa',address=>'bbb') or die
+();
$person->write();