mirror of
https://codeberg.org/scip/Config-General.git
synced 2025-12-16 20:21:01 +01:00
2.09 - added bugfix in '#' comment parsing. If current state
was within a block, then /^ #/ was not ignored as comment but instead added as variable. Reported by Lupe Christoph <lupe@lupe-christoph.de> - added -StrictObjects parameter support in the following ::Extended methods: hash() and value(). - added better parameter checks in the ::Extended::obj() method. Its now no more possible to create a new (sub-) object from an undefined key or a key which does not point to a hash reference. - simplified storing of ConfigFile and ConfigHash in new() removed my variable $configfile. - the original parameter list will now be saved, which is required for ::Extended to create new objects with the same config as their parents. git-svn-id: http://dev.catalyst.perl.org/repos/Config-General/trunk@35 be1acefe-a474-0410-9a34-9b3221f2030f
This commit is contained in:
@@ -23,7 +23,7 @@ use vars qw(@ISA @EXPORT);
|
||||
use strict;
|
||||
|
||||
|
||||
$Config::General::Extended::VERSION = "1.8";
|
||||
$Config::General::Extended::VERSION = "1.9";
|
||||
|
||||
|
||||
sub new {
|
||||
@@ -40,15 +40,21 @@ sub obj {
|
||||
#
|
||||
my($this, $key) = @_;
|
||||
if (exists $this->{config}->{$key}) {
|
||||
if (!$this->{config}->{$key}) {
|
||||
return $this->SUPER::new( -ExtendedAccess => 1, -ConfigHash => {} ); # empty object!
|
||||
if (!$this->{config}->{$key} || ref($this->{config}->{$key}) ne "HASH") {
|
||||
if ($this->{StrictObjects}) {
|
||||
croak "key \"$key\" does not point to a hash reference!\n";
|
||||
}
|
||||
else {
|
||||
# be cool, create an empty object!
|
||||
return $this->SUPER::new( -ExtendedAccess => 1, -ConfigHash => {}, %{$this->{Params}} );
|
||||
}
|
||||
}
|
||||
else {
|
||||
return $this->SUPER::new( -ExtendedAccess => 1, -ConfigHash => $this->{config}->{$key} );
|
||||
return $this->SUPER::new( -ExtendedAccess => 1, -ConfigHash => $this->{config}->{$key}, %{$this->{Params}} );
|
||||
}
|
||||
}
|
||||
else {
|
||||
return $this->SUPER::new( -ExtendedAccess => 1, -ConfigHash => $this->{config} );
|
||||
return $this->SUPER::new( -ExtendedAccess => 1, -ConfigHash => $this->{config}, %{$this->{Params}} );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +69,17 @@ sub value {
|
||||
$this->{config}->{$key} = $value;
|
||||
}
|
||||
else {
|
||||
return $this->{config}->{$key} if(exists $this->{config}->{$key});
|
||||
if (exists $this->{config}->{$key}) {
|
||||
return $this->{config}->{$key};
|
||||
}
|
||||
else {
|
||||
if ($this->{StrictObjects}) {
|
||||
croak "Key \"$key\" does not exist within current object\n";
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +90,17 @@ sub hash {
|
||||
# as hash
|
||||
#
|
||||
my($this, $key) = @_;
|
||||
return %{$this->{config}->{$key}} if(exists $this->{config}->{$key});
|
||||
if (exists $this->{config}->{$key}) {
|
||||
return %{$this->{config}->{$key}};
|
||||
}
|
||||
else {
|
||||
if ($this->{StrictObjects}) {
|
||||
croak "Key \"$key\" does not exist within current object\n";
|
||||
}
|
||||
else {
|
||||
return ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +110,15 @@ sub array {
|
||||
# as array
|
||||
#
|
||||
my($this, $key) = @_;
|
||||
return @{$this->{config}->{$key}} if(exists $this->{config}->{$key});
|
||||
if (exists $this->{config}->{$key}) {
|
||||
return @{$this->{config}->{$key}};
|
||||
}
|
||||
if ($this->{StrictObjects}) {
|
||||
croak "Key \"$key\" does not exist within current object\n";
|
||||
}
|
||||
else {
|
||||
return ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -232,10 +266,10 @@ sub AUTOLOAD {
|
||||
}
|
||||
elsif (exists $this->{config}->{$key}) {
|
||||
if ($this->is_hash($key)) {
|
||||
croak "\"$key\" points to a hash and cannot be automatically accessed\n";
|
||||
croak "Key \"$key\" points to a hash and cannot be automatically accessed\n";
|
||||
}
|
||||
elsif ($this->is_array($key)) {
|
||||
croak "\"$key\" points to an array and cannot be automatically accessed\n";
|
||||
croak "Key \"$key\" points to an array and cannot be automatically accessed\n";
|
||||
}
|
||||
else {
|
||||
return $this->{config}->{$key};
|
||||
@@ -243,11 +277,11 @@ sub AUTOLOAD {
|
||||
}
|
||||
else {
|
||||
if ($this->{StrictObjects}) {
|
||||
croak "\"$key\" does not exist within current object\n";
|
||||
croak "Key \"$key\" does not exist within current object\n";
|
||||
}
|
||||
else {
|
||||
# be cool
|
||||
return undef;
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -505,7 +539,7 @@ Thomas Linden <tom@daemon.de>
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
1.8
|
||||
1.9
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
Reference in New Issue
Block a user