Skip to content

Commit 5c49936

Browse files
committed
Refactored so #96 works when minified.
1 parent 98431ca commit 5c49936

File tree

3 files changed

+59
-13
lines changed

3 files changed

+59
-13
lines changed

dist/angular-data.js

+29-6
Original file line numberDiff line numberDiff line change
@@ -4180,6 +4180,29 @@ function Resource(utils, options) {
41804180
}
41814181
}
41824182

4183+
var methodsToProxy = [
4184+
'bindAll',
4185+
'bindOne',
4186+
'create',
4187+
'createInstance',
4188+
'destroy',
4189+
'destroyAll',
4190+
'filter',
4191+
'find',
4192+
'findAll',
4193+
'get',
4194+
'hasChanges',
4195+
'inject',
4196+
'lastModified',
4197+
'lastSaved',
4198+
'loadRelations',
4199+
'previous',
4200+
'refresh',
4201+
'save',
4202+
'update',
4203+
'updateAll'
4204+
];
4205+
41834206
/**
41844207
* @doc method
41854208
* @id DS.sync_methods:defineResource
@@ -4334,17 +4357,17 @@ function defineResource(definition) {
43344357
};
43354358

43364359
// Proxy DS methods with shorthand ones
4337-
DS.utils.forOwn(DS, function (func, name) {
4338-
if (angular.isFunction(func) && func.toString().substr(0, 37).indexOf('(resourceName,') !== -1) {
4360+
angular.forEach(methodsToProxy, function (name) {
4361+
if (name === 'bindOne' || name === 'bindAll') {
43394362
def[name] = function () {
43404363
var args = Array.prototype.slice.call(arguments);
4341-
args.unshift(def.name);
4342-
return func.apply(DS, args);
4364+
args.splice(2, 0, def.name);
4365+
return DS[name].apply(DS, args);
43434366
};
4344-
} else if (name === 'bindOne' || name === 'bindAll') {
4367+
} else {
43454368
def[name] = function () {
43464369
var args = Array.prototype.slice.call(arguments);
4347-
args.splice(2, 0, def.name);
4370+
args.unshift(def.name);
43484371
return DS[name].apply(DS, args);
43494372
};
43504373
}

0 commit comments

Comments
 (0)