From 004503861973959d892c2925767abab477c79a0c Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Mon, 8 Nov 2010 17:03:31 -0800 Subject: [PATCH] fix the result passed to related data getter callbacks --- lib/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/index.js b/lib/index.js index 68679ca..d28fa4a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -149,14 +149,15 @@ function createResource(route, options) { unpack = unpack || onlyProp var dataProp = '_' + 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) { return this._fetch({ prop: dataProp , route: route || this._route + '/' + prop - , processData: function(d) { - getter(this, dataProp, function() { return camelize(unpack(d)) }, - {configurable: true}) - }.bind(this) - , result: function(resource) { return resource[dataProp] } + , processData: processData.bind(this) + , result: result.bind(this) }, cb.bind(this), force) } return resource