aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2017-04-26 07:53:05 +0200
committerPatrick Spek <p.spek@tyil.nl>2023-07-25 02:16:09 +0200
commitee262705e8193863cb7dfcf421c30609930cc428 (patch)
treea86da52ebed362f7c622937026554dcaf81e1abe /lib
parent1716058c5a97828fd5654354be71ce5adf337e40 (diff)
Make .read() merge the hashes and allow an array of paths to load
Diffstat (limited to 'lib')
-rw-r--r--lib/Config.pm614
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Config.pm6 b/lib/Config.pm6
index 2fa01bf..372eb3b 100644
--- a/lib/Config.pm6
+++ b/lib/Config.pm6
@@ -2,6 +2,8 @@
use v6.c;
+use Hash::Merge;
+
use Config::Exception::MissingParserException;
use Config::Exception::UnknownTypeException;
use Config::Exception::FileNotFoundException;
@@ -109,15 +111,23 @@ class Config is export
}
require ::($!parser);
- $!content = ::($!parser).read($path);
+
+ $!content.merge(::($!parser).read($path));
}
return True;
}
+ multi method read(Array $paths, Str $parser = "")
+ {
+ for $paths -> $path {
+ self.read($path, $parser);
+ }
+ }
+
multi method read(Hash $hash)
{
- $!content = $hash;
+ $!content.merge($hash);
}
method set(Str $key, Any $value)