HashObject: add $dont_save parameter to set()

This commit is contained in:
Pragmatic Software 2018-08-05 22:43:57 -07:00
parent d29eb06cc5
commit 4e996717c8
1 changed files with 3 additions and 5 deletions

View File

@ -148,9 +148,7 @@ sub clear {
} }
sub find_hash { sub find_hash {
my ($self, $keyword, $arguments) = @_; my ($self, $keyword) = @_;
my $string = "$keyword" . (defined $arguments ? " $arguments" : "");
my $result = eval { my $result = eval {
foreach my $index (keys %{ $self->hash }) { foreach my $index (keys %{ $self->hash }) {
@ -196,7 +194,7 @@ sub levenshtein_matches {
} }
sub set { sub set {
my ($self, $index, $key, $value) = @_; my ($self, $index, $key, $value, $dont_save) = @_;
my $hash_index = $self->find_hash($index); my $hash_index = $self->find_hash($index);
@ -221,7 +219,7 @@ sub set {
$value = $self->hash->{$hash_index}{$key}; $value = $self->hash->{$hash_index}{$key};
} else { } else {
$self->hash->{$hash_index}{$key} = $value; $self->hash->{$hash_index}{$key} = $value;
$self->save(); $self->save() unless $dont_save;
} }
return "[$self->{name}] $hash_index: '$key' " . (defined $value ? "set to '$value'" : "is not set."); return "[$self->{name}] $hash_index: '$key' " . (defined $value ? "set to '$value'" : "is not set.");