Sha256: 51bbe9490afb03c66f2e3635fff17a319b3acd9c985267b3146ecc7f6831c495

Contents?: true

Size: 1.03 KB

Versions: 26

Compression:

Stored size: 1.03 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 = 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

26 entries across 26 versions & 1 rubygems

Version Path
ende-0.3.13 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.3.12 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.3.11 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.3.10 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.3.9 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.3.8 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.3.7 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.3.6 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.3.5 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.3.4 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.3.3 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.3.2 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.3.1 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.3.0 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.2.21 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.2.20 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.2.19 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.2.18 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.2.17 vendor/components/indefinido-indemma/lib/record/storable.js
ende-0.2.16 vendor/components/indefinido-indemma/lib/record/storable.js