Object-InsideOut - Re: OIO and default value

Posted on Fri Dec 8 18:30:59 2006 by jdhedden in response to 3732 (See the whole thread of 13)
Re: OIO and default value
Doh! I forgot that after taking out the :Arg attribute, I needed to store the data directly. Sorry.
#!/usr/bin/perl use strict; use warnings; package Connection; { use Object::InsideOut; my @bidule :Field :Set(name => 'set_bidule', restricted => 1); 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
Direct Responses: 3735 | Write a response