aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2017-11-22 18:14:29 +0100
committerPatrick Spek <p.spek@tyil.nl>2023-07-25 02:16:43 +0200
commit62877bfca2abbdc0a26cd02a743b25078efb87c1 (patch)
treec96c8c3c5f64ee8937db3a5cb01584ab2dfe226b /lib
parentff227edcd28b321f701dda00b211a883ec552060 (diff)
Move some code around and add doc to keys method
Diffstat (limited to 'lib')
-rw-r--r--lib/Config.pm629
1 files changed, 15 insertions, 14 deletions
diff --git a/lib/Config.pm6 b/lib/Config.pm6
index ad9be8a..91fafc2 100644
--- a/lib/Config.pm6
+++ b/lib/Config.pm6
@@ -110,6 +110,7 @@ class Config is Associative is export
defined($index);
}
+ #| Return a sorted list of all available keys in the current Config.
method keys()
{
my @keys;
@@ -121,20 +122,6 @@ class Config is Associative is export
@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()
@@ -262,4 +249,18 @@ class Config is Associative is export
{
self.set($key, new);
}
+
+ 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;
+ }
}