2.07 - fixed cpan bugid #1351, SaveConfig contained a deprecated

function call which caused the module to croak.
         - added feature request, if in extended mode (OOP turned
           on with -ExtendedAccess => 1 access to non-existent keys	
           caused a croak. While this is still the default behavior
           it is now possible to turn this off using -StrictObjects => 0.
         - added this to the related pod section in ::Extended.
         - fixed bug in new() which caused a couple of errors
           if the ConfigFile parameter is not set, or is set to
           undef. In this case it will now simply create an empty
           object.
         - fixed related bug in save_file() which will save "" to
           a file now if the config is uninitialized (i.e. the case
           mentioned below arrived).


git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@33 be1acefe-a474-0410-9a34-9b3221f2030f
This commit is contained in:
Thomas von Dein
2009-10-10 16:23:39 +00:00
parent 48b04e2f55
commit 41b311f7a0
4 changed files with 58 additions and 13 deletions

View File

@@ -242,7 +242,13 @@ sub AUTOLOAD {
}
}
else {
croak "\"$key\" does not exist within current object\n";
if ($this->{StrictObjects}) {
croak "\"$key\" does not exist within current object\n";
}
else {
# be cool
return undef;
}
}
}
@@ -466,6 +472,10 @@ This notation supports only scalar values! You need to make sure, that the block
<person> does not contain any subblock or multiple identical options(which will become
an array after parsing)!
If you access a non-existent key this way, Config::General will croak an error.
You can turn this behavior off by setting B<-StrictObjects> to 0 or "no". In
this case undef will be returned.
Of course you can use this kind of methods for writing data too:
$person->name("Neustein");