Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: Overriding arguments in Class::Std superclass constructors

by jdhedden (Deacon)
on Aug 11, 2006 at 15:59 UTC ( #566873=note: print w/replies, xml ) Need Help??

in reply to Overriding arguments in Class::Std superclass constructors

Try using Object::InsideOut. It will do just what you want:
#!/usr/bin/perl use strict; use warnings; package My::Class; { use Object::InsideOut; my @value :Field('Accessor' => 'value'); my %init_args :InitArgs = ( 'value' => { 'Field' => \@value, 'Mandatory' => 1, }, ); } package My::Class::Sub; { use Object::InsideOut qw(My::Class); sub _preinit :PreInit { my ($self, $args) = @_; $args->{'value'} = 23; } } package main; my $obj = My::Class::Sub->new(); print($obj->value(), "\n");

Remember: There's always one more bug.

Replies are listed 'Best First'.
Re^2: Overriding arguments in Class::Std superclass constructors
by fce2 (Sexton) on Aug 13, 2006 at 03:46 UTC
    Unfortunately I didn't learn about Object::InsideOut until a few weeks into this project, so its too late to switch. Possibly for the next version, we'll see. Thanks for the example though, its good to know the possibility exists.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://566873]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2022-09-25 15:27 GMT
Find Nodes?
    Voting Booth?
    I prefer my indexes to start at:

    Results (116 votes). Check out past polls.