From cac9a5f9e429d2461bd2830bc983eced5ef14e1a Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Wed, 26 Apr 2017 07:53:05 +0200 Subject: Make .read() merge the hashes and allow an array of paths to load --- lib/Config.pm6 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib') 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) -- cgit v1.1