From 10c2bd55f7fcdae2235a2df1cd9373c23477f93c Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Mon, 24 Apr 2017 08:45:45 +0200 Subject: Sort Config methods alphabetically --- lib/Config.pm6 | 114 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 57 insertions(+), 57 deletions(-) (limited to 'lib') 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); + } } -- cgit v1.1