aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2017-07-29 02:09:03 +0200
committerPatrick Spek <p.spek@tyil.nl>2023-07-25 02:16:26 +0200
commit3883927dfde5338001a45043384ffad7fa870f6a (patch)
treef0fab412bfd80024039ad6005a058cf422740ba4 /lib
parent14b70200e131a55a69d9c4d335bc4a388576eea3 (diff)
Initial draft for associative indexing
Diffstat (limited to 'lib')
-rw-r--r--lib/Config.pm627
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/Config.pm6 b/lib/Config.pm6
index f0a75c3..63a5e7a 100644
--- a/lib/Config.pm6
+++ b/lib/Config.pm6
@@ -8,7 +8,7 @@ use Config::Exception::MissingParserException;
use Config::Exception::FileNotFoundException;
use Config::Parser;
-class Config is export
+class Config is Associative is export
{
has Hash $!content = {};
has Str $!path = "";
@@ -209,4 +209,29 @@ class Config is export
require ::($chosen-parser);
return ::($chosen-parser).write($path, $!content);
}
+
+ multi method AT-KEY(::?CLASS:D: $key)
+ {
+ $self.get($key);
+ }
+
+ multi method EXISTS-KEY(::?CLASS:D: $key)
+ {
+ $self.has($key);
+ }
+
+ multi method DELETE-KEY(::?CLASS:D: $key)
+ {
+ $self.unset($key);
+ }
+
+ multi method ASSIGN-KEY(::?CLASS:D: $key, $new)
+ {
+ $self.set($key, $new);
+ }
+
+ multi method BIND-KEY(::?CLASS:D: $key, \new)
+ {
+ $self.set($key, new);
+ }
}