aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2017-04-26 08:59:30 +0200
committerPatrick Spek <p.spek@tyil.nl>2023-07-25 02:16:16 +0200
commit9ba1d672dded96a493f3ce9dcb46554d7821b6ff (patch)
tree152fd7c4a7ce037e189dce46385d5d0c53c4a2fb /lib
parenteda0b3cd42e8a3c760454ec14bf37f34f8edaaea (diff)
Fix the easy bugs
Diffstat (limited to 'lib')
-rw-r--r--lib/Config.pm630
1 files changed, 16 insertions, 14 deletions
diff --git a/lib/Config.pm6 b/lib/Config.pm6
index b9bc582..22cd2a3 100644
--- a/lib/Config.pm6
+++ b/lib/Config.pm6
@@ -34,16 +34,16 @@ class Config is export
#| key, use a . to descent a level.
multi method get(Str $key, Any $default = Nil)
{
- self.get($key.split("."), $default);
+ self.get($key.split(".").list, $default);
}
- #| Get a value from the config object using an array
+ #| Get a value from the config object using a list
#| to indicate the nested key to get.
- multi method get(Array $keyparts, Any $default = Nil)
+ multi method get(List $keyparts, Any $default = Nil)
{
my $index = $!content;
- for $keyparts -> $part {
+ for $keyparts.list -> $part {
return $default unless defined($index{$part});
$index = $index{$part};
@@ -91,20 +91,22 @@ class Config is export
#| Check wether a given key exists.
multi method has(Str $key) {
- self.has($key.split("."));
+ self.has($key.split(".").list);
}
- #| Check wether a given key exists using an array to supply
+ #| Check wether a given key exists using a list to supply
#| the nested key to check.
- multi method has(Array $keyparts)
+ multi method has(List $keyparts)
{
my $index = $!content;
- for $keyparts -> $part {
+ for $keyparts.list -> $part {
return False unless defined($index{$part});
$index = $index{$part};
}
+
+ defined($index);
}
#| Reload the configuration. Requires the configuration to
@@ -146,11 +148,11 @@ class Config is export
return True;
}
- #| Read an array of paths. Will fail on the first file that
+ #| Read a list of paths. Will fail on the first file that
#| fails to load for whatever reason.
- multi method read(Array $paths, Str $parser = "")
+ multi method read(List $paths, Str $parser = "")
{
- for $paths -> $path {
+ for $paths.list -> $path {
self.read($path, $parser);
}
@@ -168,14 +170,14 @@ class Config is export
#| Set a single key to a given value;
multi method set(Str $key, Any $value)
{
- self.set($key.split("."), $value);
+ self.set($key.split(".").list, $value);
}
- multi method set(Array $keyparts, Any $value)
+ multi method set(List $keyparts, Any $value)
{
my $index := $!content;
- for $keyparts -> $part {
+ for $keyparts.list -> $part {
$index{$part} = {} unless defined($index{$part});
$index := $index{$part};