Skip to content

Commit

Permalink
Refactored so #96 works when minified.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdobry committed Jul 20, 2014
1 parent 98431ca commit 5c49936
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 13 deletions.
35 changes: 29 additions & 6 deletions dist/angular-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -4180,6 +4180,29 @@ function Resource(utils, options) {
}
}

var methodsToProxy = [
'bindAll',
'bindOne',
'create',
'createInstance',
'destroy',
'destroyAll',
'filter',
'find',
'findAll',
'get',
'hasChanges',
'inject',
'lastModified',
'lastSaved',
'loadRelations',
'previous',
'refresh',
'save',
'update',
'updateAll'
];

/**
* @doc method
* @id DS.sync_methods:defineResource
Expand Down Expand Up @@ -4334,17 +4357,17 @@ function defineResource(definition) {
};

// Proxy DS methods with shorthand ones
DS.utils.forOwn(DS, function (func, name) {
if (angular.isFunction(func) && func.toString().substr(0, 37).indexOf('(resourceName,') !== -1) {
angular.forEach(methodsToProxy, function (name) {
if (name === 'bindOne' || name === 'bindAll') {
def[name] = function () {
var args = Array.prototype.slice.call(arguments);
args.unshift(def.name);
return func.apply(DS, args);
args.splice(2, 0, def.name);
return DS[name].apply(DS, args);
};
} else if (name === 'bindOne' || name === 'bindAll') {
} else {
def[name] = function () {
var args = Array.prototype.slice.call(arguments);
args.splice(2, 0, def.name);
args.unshift(def.name);
return DS[name].apply(DS, args);
};
}
Expand Down
Loading

0 comments on commit 5c49936

Please sign in to comment.