diff options
author | Patrick Spek <p.spek@tyil.nl> | 2017-07-29 02:09:03 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2017-07-29 02:09:03 +0200 |
commit | a913899f0ce3394501ee721b7e8c30f68a1cb133 (patch) | |
tree | f0fab412bfd80024039ad6005a058cf422740ba4 /lib/Config.pm6 | |
parent | 4151e0f92ff2ddc4b2f874de2dbe2c8629e9a33e (diff) |
Initial draft for associative indexing
Diffstat (limited to 'lib/Config.pm6')
-rw-r--r-- | lib/Config.pm6 | 27 |
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); + } } |