aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2018-03-20 14:40:00 +0100
committerPatrick Spek <p.spek@tyil.nl>2023-07-25 02:16:48 +0200
commite892316068e0eebfc970d723eb2cbbd18e42a85c (patch)
treeddb309488457f29a3f456da6d0df0bdd82e88503 /lib
parentc4350a0aa97a5550e802ab92eb145b211752cd6b (diff)
Fix :delete adverb
Diffstat (limited to 'lib')
-rw-r--r--lib/Config.pm621
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Config.pm6 b/lib/Config.pm6
index 91fafc2..a4bf3af 100644
--- a/lib/Config.pm6
+++ b/lib/Config.pm6
@@ -214,6 +214,27 @@ class Config is Associative is export
self;
}
+ multi method unset(Str $key)
+ {
+ self.unset($key.split(".").Array);
+ }
+
+ multi method unset(@parts)
+ {
+ my %index := $!content;
+ my $target = @parts.pop;
+
+ for @parts.list -> $part {
+ %index{$part} = {} unless defined(%index{$part});
+
+ %index := %index{$part};
+ }
+
+ %index{$target}:delete if %index{$target}:exists;
+
+ self;
+ }
+
#| Write the current configuration to the given path. If
#| no parser is given, it tries to use the parser that
#| was used when loading the configuration.