diff options
author | Patrick Spek <p.spek@tyil.nl> | 2017-04-26 08:09:05 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2017-04-26 08:09:05 +0200 |
commit | 348a75d03fee516bb0dc0854b20336a40dd59b74 (patch) | |
tree | dd8442d67efa5214d0bda3280ecc0c012a5a8a83 /lib | |
parent | b23ea52e22e0fcebcaf4af0d39a4e2e07e3910a9 (diff) |
Add a multi method set() that accepts an array for the key
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Config.pm6 | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Config.pm6 b/lib/Config.pm6 index 2369b6f..1d0d7db 100644 --- a/lib/Config.pm6 +++ b/lib/Config.pm6 @@ -160,11 +160,16 @@ class Config is export } #| Set a single key to a given value; - method set(Str $key, Any $value) + multi method set(Str $key, Any $value) + { + self.set($key.split("."), $value); + } + + multi method set(Array $keyparts, Any $value) { my $index := $!content; - for $key.split(".") -> $part { + for $keyparts -> $part { $index{$part} = {} unless defined($index{$part}); $index := $index{$part}; |