Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Overriding arguments in Class::Std superclass constructors

by lima1 (Curate)
on Aug 11, 2006 at 14:35 UTC ( #566846=note: print w/replies, xml ) Need Help??

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

Although not exactly what you want:
mysubclass->new({ myclass => { value = 23 }});
works. another solution would be to add a default value to myclass->value so that a missing initializer label does not throw a fatal error. To set a new default value, overriding the START method seems to work:
package myclass; use Class::Std; my %value :ATTR( :name<value> :default(1)); 1;
package mysubclass; use base qw(myclass); sub START { my ($self, $ident, $arg_ref) = @_; $self->set_value(123) if !defined $arg_ref->{value}; } 1;
UPDATE: original version ignored initializer labels.

Replies are listed 'Best First'.
Re^2: Overriding arguments in Class::Std superclass constructors
by fce2 (Sexton) on Aug 13, 2006 at 04:06 UTC
    Yeah, the first sucks because I'd have to do it everywhere I create objects, and all those places have to "know" more than they should.

    My workaround is basically the same, except that I removed the init_arg and made myclass::START do the croak-or-set itself.

    Thanks for the ideas. I've opened ticket 20966 in RT.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2022-09-24 19:48 GMT
Find Nodes?
    Voting Booth?
    I prefer my indexes to start at:

    Results (115 votes). Check out past polls.