in reply to Inheritable configuration options.... but with default values?
Hi, I would use Moo for all your object creation needs if I were you.
package MyBase { use Moo; has cfg => ( is => 'rw', default => sub { return { on_error => 'exit', output_type => 'text' }; }, ); }; package MyChild { use Moo; extends 'MyBase'; sub BUILD { shift->cfg->{on_error} = 'warn'; } }; use strict; use warnings; use MyChild; use Test::More; ok( my $obj = MyChild->new ); is_deeply( $obj->cfg, { on_error => 'warn', output_type => 'text' } ); done_testing;
Hope this helps!
|
|---|