Comparing version 0.3.24 to 0.3.25
@@ -48,2 +48,3 @@ // Generated by CoffeeScript 1.6.2 | ||
} | ||
refModel.cache(); | ||
return refModel; | ||
@@ -50,0 +51,0 @@ }; |
@@ -12,5 +12,4 @@ // Generated by CoffeeScript 1.6.2 | ||
*/ | ||
function Cache(model, _prepData) { | ||
function Cache(model) { | ||
this.model = model; | ||
this._prepData = _prepData; | ||
this._data = {}; | ||
@@ -26,3 +25,3 @@ } | ||
Cache.prototype.prepare = function() { | ||
Cache.prototype.storeModel = function() { | ||
if (this._prepared) { | ||
@@ -32,3 +31,3 @@ return; | ||
this._prepared = true; | ||
return this.store(JSON.parse(JSON.stringify(this._prepData))); | ||
return this.store(this.model.normalize()); | ||
}; | ||
@@ -35,0 +34,0 @@ |
@@ -50,3 +50,2 @@ // Generated by CoffeeScript 1.6.2 | ||
} | ||
options.model._cache.prepare(); | ||
payload = this._getPayload(options); | ||
@@ -53,0 +52,0 @@ model = payload.model; |
@@ -80,2 +80,5 @@ // Generated by CoffeeScript 1.6.2 | ||
}; | ||
model.cache = function() { | ||
return model._cache.storeModel(); | ||
}; | ||
if (this.rootField.options.methods) { | ||
@@ -82,0 +85,0 @@ for (methodName in this.rootField.options.methods) { |
{ | ||
"name": "linen", | ||
"version": "0.3.24", | ||
"version": "0.3.25", | ||
"description": "Linen (line-in) maps API's to [bindable](/classdojo/bindable.js) `objects`, and `collections`. At [classdojo](http://classdojo.com), we use `linen` to abstract our API from front-end, so we don't necessarily depend on any sort of API while developing new components. This allows us to rapidly build prototypes which can be wired up later.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -76,2 +76,58 @@ var linen = require("../.."), | ||
}); | ||
it("doesn't send data if a field is a reference", function(next) { | ||
var getCount = 0, | ||
putModelCount = 0, | ||
putCount = 0, | ||
l = linen(); | ||
l.schema("person", { | ||
name: "string", | ||
changed: { | ||
$request: { | ||
put: function(payload, next) { | ||
putCount++; | ||
next(); | ||
} | ||
} | ||
}, | ||
address: { | ||
$ref: "address" | ||
}, | ||
$request: { | ||
get: function(payload, next) { | ||
getCount++; | ||
next(); | ||
}, | ||
put: function(payload, next) { | ||
putModelCount++; | ||
next(); | ||
} | ||
} | ||
}); | ||
l.schema("address", { | ||
name: "string", | ||
address: { | ||
$ref: "address" | ||
}, | ||
$request: { | ||
get: function(payload, next) { | ||
next(); | ||
} | ||
} | ||
}); | ||
var m = l.model("person", { _id: "adda", address: "abba" }); | ||
m.load(function() { | ||
expect(getCount).to.be(1); | ||
m.set("changed", true); | ||
m.save(function() { | ||
expect(putCount).to.be(1); | ||
expect(putModelCount).to.be(0); | ||
next(); | ||
}); | ||
}) | ||
}); | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8106783
243204