diff options
author | Patrick Spek <p.spek@tyil.nl> | 2017-04-24 08:45:45 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2017-04-24 08:45:45 +0200 |
commit | 10c2bd55f7fcdae2235a2df1cd9373c23477f93c (patch) | |
tree | 7daf7b00506312d102c6a2af45162fcac7586378 /lib/Config.pm6 | |
parent | 940c920c6ca61e0690ad5a8c8e1aaa65e06bc46f (diff) |
Sort Config methods alphabetically
Diffstat (limited to 'lib/Config.pm6')
-rw-r--r-- | lib/Config.pm6 | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/lib/Config.pm6 b/lib/Config.pm6 index 16aa7f7..4078d73 100644 --- a/lib/Config.pm6 +++ b/lib/Config.pm6 @@ -14,36 +14,6 @@ class Config is export has $!path; has $!parser; - multi method read() - { - return self.load($!path); - } - - multi method read(Str $path, Str $parser = "") - { - Config::Exception::FileNotFoundException.new.throw() unless $path.IO.f; - - $!parser = self.get-parser($path, $parser); - - require ::($!parser); - $!content = ::($!parser).read($path); - - return True; - } - - multi method read(Hash $hash) - { - $!content = $hash; - } - - method write(Str $path, Str $parser = "") - { - $parser = self.get-parser($path, $parser); - - require ::($parser); - return ::($parser).write($path, $!content); - } - multi method get(Str $key, Any $default = Nil) { my $index = $!content; @@ -70,33 +40,6 @@ class Config is export $index; } - method has(Str $key) { - my $index = $!content; - - for $key.split(".") -> $part { - return False unless defined($index{$part}); - - $index = $index{$part}; - } - - True; - } - - method set(Str $key, Any $value) - { - my $index := $!content; - - for $key.split(".") -> $part { - $index{$part} = {} unless defined($index{$part}); - - $index := $index{$part}; - } - - $index = $value; - - self; - } - method get-parser(Str $path, Str $parser = "") { if ($parser ne "") { @@ -128,4 +71,61 @@ class Config is export return Config::Type::unknown; } + + method has(Str $key) { + my $index = $!content; + + for $key.split(".") -> $part { + return False unless defined($index{$part}); + + $index = $index{$part}; + } + + True; + } + + multi method read() + { + return self.load($!path); + } + + multi method read(Str $path, Str $parser = "") + { + Config::Exception::FileNotFoundException.new.throw() unless $path.IO.f; + + $!parser = self.get-parser($path, $parser); + + require ::($!parser); + $!content = ::($!parser).read($path); + + return True; + } + + multi method read(Hash $hash) + { + $!content = $hash; + } + + method set(Str $key, Any $value) + { + my $index := $!content; + + for $key.split(".") -> $part { + $index{$part} = {} unless defined($index{$part}); + + $index := $index{$part}; + } + + $index = $value; + + self; + } + + method write(Str $path, Str $parser = "") + { + $parser = self.get-parser($path, $parser); + + require ::($parser); + return ::($parser).write($path, $!content); + } } |