Object-InsideOut - Re: OIO and default value

Posted on Fri Dec 8 19:57:29 2006 by gaetan in response to 3734 (See the whole thread of 13)
Re: OIO and default value
Yeap, it it 6:50pm in France. I will have to leave my office in a few minutes

OK, the previous code is working, but when applying your "recipe" for my program, it does not work

If you add some lines in the code, the program fails

#!/usr/bin/perl use strict; use warnings; package Connection; { use Object::InsideOut; my @bidule :Field :Set(name => 'set_bidule', restricted => 1); my @truc # here the 3 added lines :Field :Arg(name => "truc"); sub init :Init { my ($self, $args) = @_; # Set default, if needed if (! exists($args->{'bidule'})) { $args->{'bidule'} = 0; } # Store value $self->set(\@bidule, $args->{'bidule'}); } sub print_information { my $obj = shift; print "Bidule: $bidule[$$obj]\n"; } } package Connection::Simulate; { use Object::InsideOut('Connection'); sub pre :PreInit { my ($self, $args) = @_; # Set default, if needed if (! exists($args->{'bidule'})) { $args->{'bidule'} = 1; } } } package main; my $sim = Connection::Simulate->new(); $sim->print_information(); my $con = Connection->new(); $con->print_information(); print("Done\n"); exit(0); # EOF
I obtain the following result:
{go}606: perl ~/tmp/toto.pl Bidule: 0 Bidule: 0 Done

I need help (only for next Monday ;-))

Gaetan
Direct Responses: 3738 | Write a response