From 62877bfca2abbdc0a26cd02a743b25078efb87c1 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 22 Nov 2017 18:14:29 +0100 Subject: Move some code around and add doc to keys method --- lib/Config.pm6 | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'lib') 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; + } } -- cgit v1.1