Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Inheritable configuration options.... but with default values?

by haukex (Archbishop)
on Feb 20, 2020 at 17:58 UTC ( [id://11113268]=note: print w/replies, xml ) Need Help??


in reply to Inheritable configuration options.... but with default values?

To make full (and "correct") use of OO, the properties need to be encapsulated.

use warnings; use strict; package CfgBase { use Moo; use namespace::clean; has on_error => (is => 'ro', default => "exit"); has output_type => (is => 'ro', default => "text"); sub dump { my $self = shift; print ref($self),":\n"; print " $_: ",$self->$_,"\n" for qw/ on_error output_type /; } } package CfgChild { use Moo; use namespace::clean; extends 'CfgBase'; has '+on_error' => (default => "warn"); } CfgBase->new->dump; CfgChild->new->dump;
  • Comment on Re: Inheritable configuration options.... but with default values?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-19 13:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found