mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
dbf7d33c88
refs https://github.com/TryGhost/Team/issues/1104 - `.get('key')` would error because it was incorrectly expecting the internal content object to contain `{key, value}` objects - changed `.getAll()` to return a shallow copy of the internal content object so we don't leak references that can result in unexpected changes to the cache content - changed the internal content object naming to `_content` to highlight that it's an internal/private implementation detail rather than a public API
28 lines
521 B
JavaScript
28 lines
521 B
JavaScript
module.exports = class CustomThemeSettingsCache {
|
|
constructor() {
|
|
this._content = new Object();
|
|
}
|
|
|
|
get(key) {
|
|
return this._content[key];
|
|
}
|
|
|
|
getAll() {
|
|
return Object.assign({}, this._content);
|
|
}
|
|
|
|
populate(settings) {
|
|
this.clear();
|
|
|
|
settings.forEach((setting) => {
|
|
this._content[setting.key] = setting.value;
|
|
});
|
|
}
|
|
|
|
clear() {
|
|
for (const key in this._content) {
|
|
delete this._content[key];
|
|
}
|
|
}
|
|
};
|