Skip to content

Commit

Permalink
Fix addRestangularMethodFunction to handle post/put/delete properly
Browse files Browse the repository at this point in the history
  • Loading branch information
leahciMic committed Oct 15, 2014
1 parent 00ea6c7 commit 1a8fbe0
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/restangular.js
Original file line number Diff line number Diff line change
Expand Up @@ -1243,13 +1243,10 @@ module.provider('Restangular', function() {

function addRestangularMethodFunction(name, operation, path, defaultParams, defaultHeaders, defaultElem) {
var newRestangularObject,
createdFunction;
createdFunction,
urlBuilder = operation === 'getList' ? 'all' : 'one';

if (operation === 'getList') {
newRestangularObject = this.all(path);
} else {
newRestangularObject = this.one(path);
}
newRestangularObject = this[urlBuilder](path);

createdFunction = function(params, headers, elem) {
var params, headers, elem;
Expand All @@ -1258,7 +1255,15 @@ module.provider('Restangular', function() {
headers = _.defaults(headers, defaultHeaders);
elem = _.defaults(elem, defaultElem);

return newRestangularObject[operation](params, headers, elem);
return newRestangularObject.customOperation(
// umm, so the documentation specifies delete is one of the operations
// that can be pased to customOperation, but it totally means remove?
operation === 'delete' ? 'remove' : operation,
'',
params,
headers,
elem
);
};

if (config.isSafe(operation)) {
Expand Down

0 comments on commit 1a8fbe0

Please sign in to comment.