betajs/betajs-data

View on GitHub
src/data/stores/dumb/assoc_dumb_store.js

Summary

Maintainability
A
0 mins
Test Coverage
Scoped.define("module:Stores.AssocDumbStore", ["module:Stores.DumbStore"], function (DumbStore, scoped) {
    return DumbStore.extend({scoped: scoped}, {

        _read_key: function (key) {},
        _write_key: function (key, value) {},
        _remove_key: function (key) {},

        __read_id: function (key) {
            var raw = this._read_key(key);
            return raw ? parseInt(raw, 10) : null;
        },

        _read_last_id: function () {
            return this.__read_id("last_id");
        },

        _write_last_id: function (id) {
            this._write_key("last_id", id);
        },

        _remove_last_id: function () {
            this._remove_key("last_id");
        },

        _read_first_id: function () {
            return this.__read_id("first_id");
        },

        _write_first_id: function (id) {
            this._write_key("first_id", id);
        },

        _remove_first_id: function () {
            this._remove_key("first_id");
        },

        _read_item: function (id) {
            return this._read_key("item_" + id);
        },

        _write_item: function (id, data) {
            this._write_key("item_" + id, data);
        },

        _remove_item: function (id) {
            this._remove_key("item_" + id);
        },

        _read_next_id: function (id) {
            return this.__read_id("next_" + id);
        },

        _write_next_id: function (id, next_id) {
            this._write_key("next_" + id, next_id);
        },

        _remove_next_id: function (id) {
            this._remove_key("next_" + id);
        },

        _read_prev_id: function (id) {
            return this.__read_id("prev_" + id);
        },

        _write_prev_id: function (id, prev_id) {
            this._write_key("prev_" + id, prev_id);
        },

        _remove_prev_id: function (id) {
            this._remove_key("prev_" + id);
        }

    });
});