TryGhost/Ghost

View on GitHub
ghost/custom-theme-settings-service/lib/CustomThemeSettingsCache.js

Summary

Maintainability
A
0 mins
Test Coverage
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];
        }
    }
};