diff options
author | Patrick Spek <p.spek@tyil.nl> | 2017-11-22 18:14:29 +0100 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2017-11-22 18:14:29 +0100 |
commit | 00304cbbe11de47767d5470e12d3286c71c704ae (patch) | |
tree | c96c8c3c5f64ee8937db3a5cb01584ab2dfe226b /lib/Config.pm6 | |
parent | 8d2fa4af887b2dc77c0a2d1c631757f36fef38a8 (diff) |
Move some code around and add doc to keys method
Diffstat (limited to 'lib/Config.pm6')
-rw-r--r-- | lib/Config.pm6 | 29 |
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; + } } |