From fe7e117ee12678095ddbdc7b68907e8b9ad48ae6 Mon Sep 17 00:00:00 2001
From: Patrick Spek
Date: Tue, 20 Mar 2018 14:40:00 +0100
Subject: Fix :delete adverb
---
lib/Config.pm6 | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
(limited to 'lib')
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.
--
cgit v1.1