Sha256: 41c5cd79688c35e4fa737abf59c59b5f32f2bad655c6501713ce0012c8715a4d

Contents?: true

Size: 1.05 KB

Versions: 28

Compression:

Stored size: 1.05 KB

Contents

var extend, merge, model, record, stampit, storable;

extend = require('assimilate');

merge = extend.withStrategy('deep');

stampit = require('../../vendor/stampit');

storable = stampit({
  store: function(keypath, value, options) {
    var collection, entry, key, _i, _len;

    collection = this.database;
    keypath = keypath.toString().split('.');
    key = keypath.pop();
    for (_i = 0, _len = keypath.length; _i < _len; _i++) {
      entry = keypath[_i];
      collection[entry] || (collection[entry] = {});
      collection = collection[entry];
    }
    if (arguments.length === 1) {
      this.reads++;
      return collection[key];
    } else {
      this.writes++;
      value.sustained || (value.sustained = true);
      return collection[key] = value;
    }
  },
  values: function() {
    return Object.values(this.database);
  }
}, {
  type: 'object',
  writes: 0,
  reads: 0
}, function() {
  this.database || (this.database = {});
  return this;
});

model = window.model;

record = window.record;

model.storable = true;

module.exports = storable;

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ende-0.4.7 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.4.6 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.4.5 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.4.4 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.4.3 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.4.2 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.4.1 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.4.0 vendor/components/indefinido-indemma/lib/record/storable.js