From 435e218e4dcc413e1d74f1ad39c7882de5b9b7ee Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Wed, 4 Oct 2017 20:04:10 +0100 Subject: Allow overriding true config values with false --- lib/Iurt/Config.pm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/Iurt/Config.pm b/lib/Iurt/Config.pm index 9a4ed8b..32b87e4 100644 --- a/lib/Iurt/Config.pm +++ b/lib/Iurt/Config.pm @@ -60,7 +60,7 @@ sub config_usage { print "\n\n"; } -=head2 config_init($config_usage, $config, $rung) +=head2 config_init($config_usage, $config, $run) Create an instance of a class at runtime. I<$config_usage> is the configuration help, @@ -75,7 +75,11 @@ sub config_init { foreach my $k (keys %$config_usage) { ref $config_usage->{$k}{default} eq 'CODE' and next; - $config->{$k} ||= $run->{config}{$k} || $config_usage->{$k}{default}; + if (defined($run->{config}{$k})) { + $config->{$k} = $run->{config}{$k}; + } elsif (!defined($config->{$k})) { + $config->{$k} = $config_usage->{$k}{default}; + } } # warly 20061107 # we need to have all the default initialised before calling functions, so this @@ -83,7 +87,11 @@ sub config_init { foreach my $k (keys %$config_usage) { ref $config_usage->{$k}{default} eq 'CODE' or next; my $a = $config_usage->{$k}{default}($config, $run); - $config->{$k} ||= $run->{config}{$k} || $a; + if (defined($run->{config}{$k})) { + $config->{$k} = $run->{config}{$k}; + } elsif (!defined($config->{$k})) { + $config->{$k} = $a; + } } } -- cgit v1.2.1