aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2017-11-22 13:34:16 +0100
committerPatrick Spek <p.spek@tyil.nl>2023-07-25 02:16:40 +0200
commitd1fee36e3135ddc1382323f8db40236cef6599ce (patch)
tree6f0cbd13c843c06c90945d9d7535d640f963b9a2 /lib
parentf1aff4c119031f97bf06702079e743e2ed8941df (diff)
Implement .keys method
Diffstat (limited to 'lib')
-rw-r--r--lib/Config.pm625
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/Config.pm6 b/lib/Config.pm6
index d0c1d93..ad9be8a 100644
--- a/lib/Config.pm6
+++ b/lib/Config.pm6
@@ -110,6 +110,31 @@ class Config is Associative is export
defined($index);
}
+ method keys()
+ {
+ my @keys;
+
+ for $!content.keys -> $key {
+ @keys.append: self.extract-keys($key);
+ }
+
+ @keys.sort;
+ }
+
+ submethod extract-keys($key)
+ {
+ my $value = self.get($key);
+ return $key if $value !~~ Iterable;
+
+ my @keys;
+
+ for $value.keys -> $nested-key {
+ @keys.append: self.extract-keys("{$key}.{$nested-key}");
+ }
+
+ return @keys;
+ }
+
#| Reload the configuration. Requires the configuration to
#| have been loaded from a file.
multi method read()