mirror of
https://github.com/samsonjs/gitter.git
synced 2026-04-27 15:07:41 +00:00
fix the result passed to related data getter callbacks
This commit is contained in:
parent
ee8eb83f78
commit
0045038619
1 changed files with 6 additions and 5 deletions
11
lib/index.js
11
lib/index.js
|
|
@ -149,14 +149,15 @@ function createResource(route, options) {
|
||||||
unpack = unpack || onlyProp
|
unpack = unpack || onlyProp
|
||||||
var dataProp = '_' + prop
|
var dataProp = '_' + prop
|
||||||
, fn = 'get' + titleCaseFirst(prop)
|
, fn = 'get' + titleCaseFirst(prop)
|
||||||
|
, processData = function(d) {
|
||||||
|
getter(this, dataProp, function() { return camelize(unpack(d))})
|
||||||
|
}
|
||||||
|
, result = function(resource) { return this[dataProp] }
|
||||||
resource.prototype[fn] = function(cb, force) {
|
resource.prototype[fn] = function(cb, force) {
|
||||||
return this._fetch({ prop: dataProp
|
return this._fetch({ prop: dataProp
|
||||||
, route: route || this._route + '/' + prop
|
, route: route || this._route + '/' + prop
|
||||||
, processData: function(d) {
|
, processData: processData.bind(this)
|
||||||
getter(this, dataProp, function() { return camelize(unpack(d)) },
|
, result: result.bind(this)
|
||||||
{configurable: true})
|
|
||||||
}.bind(this)
|
|
||||||
, result: function(resource) { return resource[dataProp] }
|
|
||||||
}, cb.bind(this), force)
|
}, cb.bind(this), force)
|
||||||
}
|
}
|
||||||
return resource
|
return resource
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue