From 4e71cb06744283e815c4bf1b89b9e6a6fe9eb5f1 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Fri, 24 Apr 2020 23:04:07 -0700 Subject: [PATCH] Add object name to JSON metadata when saving --- PBot/DualIndexHashObject.pm | 2 ++ PBot/HashObject.pm | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/PBot/DualIndexHashObject.pm b/PBot/DualIndexHashObject.pm index ac48c8a1..cd65907f 100644 --- a/PBot/DualIndexHashObject.pm +++ b/PBot/DualIndexHashObject.pm @@ -113,6 +113,8 @@ sub save { $self->add('$metadata$', '$metadata$', { update_version => PBot::VERSION::BUILD_REVISION }); } + $self->set('$metadata$', '$metadata$', 'name', $self->{name}, 1); + my $json = JSON->new; my $json_text = $json->pretty->canonical->utf8->encode($self->{hash}); diff --git a/PBot/HashObject.pm b/PBot/HashObject.pm index 420479bb..7d80d4fa 100644 --- a/PBot/HashObject.pm +++ b/PBot/HashObject.pm @@ -97,6 +97,8 @@ sub save { $self->add('$metadata$', { update_version => PBot::VERSION::BUILD_REVISION }); } + $self->set('$metadata$', 'name', $self->{name}, 1); + my $json = JSON->new; my $json_text = $json->pretty->canonical->utf8->encode($self->{hash}); @@ -151,8 +153,9 @@ sub set { return $result; } - if (not defined $value) { $value = $self->{hash}->{$lc_index}->{$key}; } - else { + if (not defined $value) { + $value = $self->{hash}->{$lc_index}->{$key}; + } else { $self->{hash}->{$lc_index}->{$key} = $value; $self->save unless $dont_save; }