@@ -1242,24 +1242,28 @@ module.provider('Restangular', function() {
12421242 }
12431243
12441244 function addRestangularMethodFunction ( name , operation , path , defaultParams , defaultHeaders , defaultElem ) {
1245- var bindedFunction ;
1246- if ( operation === 'getList' ) {
1247- bindedFunction = _ . bind ( fetchFunction , this , path ) ;
1248- } else {
1249- bindedFunction = _ . bind ( customFunction , this , operation , path ) ;
1250- }
1251-
1252- var createdFunction = function ( params , headers , elem ) {
1253- var callParams = _ . defaults ( {
1254- params : params ,
1255- headers : headers ,
1256- elem : elem
1257- } , {
1258- params : defaultParams ,
1259- headers : defaultHeaders ,
1260- elem : defaultElem
1261- } ) ;
1262- return bindedFunction ( callParams . params , callParams . headers , callParams . elem ) ;
1245+ var newRestangularObject ,
1246+ createdFunction ,
1247+ urlBuilder = operation === 'getList' ? 'all' : 'one' ;
1248+
1249+ newRestangularObject = this [ urlBuilder ] ( path ) ;
1250+
1251+ createdFunction = function ( params , headers , elem ) {
1252+ var params , headers , elem ;
1253+
1254+ params = _ . defaults ( params , defaultParams ) ;
1255+ headers = _ . defaults ( headers , defaultHeaders ) ;
1256+ elem = _ . defaults ( elem , defaultElem ) ;
1257+
1258+ return newRestangularObject . customOperation (
1259+ // umm, so the documentation specifies delete is one of the operations
1260+ // that can be pased to customOperation, but it totally means remove?
1261+ operation === 'delete' ? 'remove' : operation ,
1262+ '' ,
1263+ params ,
1264+ headers ,
1265+ elem
1266+ ) ;
12631267 } ;
12641268
12651269 if ( config . isSafe ( operation ) ) {
0 commit comments