Comparing version 0.3.32 to 0.3.33
@@ -68,2 +68,5 @@ // Generated by CoffeeScript 1.6.2 | ||
}; | ||
model.loadFields = function(fields, next) { | ||
return _this.loadFields(model, fields, next); | ||
}; | ||
model.fetch = function(next) { | ||
@@ -131,2 +134,14 @@ return _this.load(model, next); | ||
Transporter.prototype.loadFields = function(model, fields, next) { | ||
return this._request({ | ||
model: model, | ||
method: "get", | ||
fields: fields | ||
}, next); | ||
}; | ||
/* | ||
*/ | ||
Transporter.prototype.reload = function(model, next) { | ||
@@ -192,6 +207,19 @@ return this._request({ | ||
Transporter.prototype._request = function(options, next) { | ||
var decor, fields, | ||
_this = this; | ||
if (next == null) { | ||
next = function() {}; | ||
} | ||
return async.forEach(this._decorators, (function(decor, next) { | ||
if (options.fields) { | ||
fields = options.fields.map(function(fieldName) { | ||
return _this.rootField.getField(fieldName); | ||
}); | ||
} else { | ||
fields = this.rootField.allFields; | ||
} | ||
decor = fields.map(function(field) { | ||
return field._transporter; | ||
}); | ||
return async.forEach(decor, (function(decor, next) { | ||
return decor.request(options, next); | ||
@@ -198,0 +226,0 @@ }), next); |
{ | ||
"name": "linen", | ||
"version": "0.3.32", | ||
"version": "0.3.33", | ||
"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", |
@@ -80,2 +80,11 @@ var linen = require("../.."), | ||
it("can explicitly load fields", function(next) { | ||
var m = s.model(); | ||
m.loadFields(["last"], function() { | ||
expect(m.get("name")).to.be(undefined); | ||
expect(m.get("last")).to.be("abba"); | ||
next(); | ||
}) | ||
}); | ||
describe("doesn't load when", function() { | ||
@@ -82,0 +91,0 @@ |
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
8119379
243496