mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-11 12:32:37 +01:00
HashObject: add $dont_save parameter to set()
This commit is contained in:
parent
d29eb06cc5
commit
4e996717c8
@ -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.");
|
||||||
|
Loading…
Reference in New Issue
Block a user