@@ -924,20 +924,16 @@ restangular.provider('Restangular', function() {
924
924
925
925
function addCustomOperation ( elem ) {
926
926
elem [ config . restangularFields . customOperation ] = _ . bind ( customFunction , elem ) ;
927
- _ . each ( [ 'put' , 'patch' , 'post' , 'get' , 'delete' ] , function ( oper ) {
927
+ var requestMethods = { get : customFunction , delete : customFunction } ;
928
+ _ . each ( [ 'put' , 'patch' , 'post' ] , function ( name ) {
929
+ requestMethods [ name ] = function ( operation , elem , path , params , headers ) {
930
+ return _ . bind ( customFunction , this ) ( operation , path , params , headers , elem ) ;
931
+ } ;
932
+ } ) ;
933
+ _ . each ( requestMethods , function ( requestFunc , name ) {
934
+ var callOperation = name === 'delete' ? 'remove' : name ;
928
935
_ . each ( [ 'do' , 'custom' ] , function ( alias ) {
929
- var callOperation = oper === 'delete' ? 'remove' : oper ;
930
- var name = alias + oper . toUpperCase ( ) ;
931
- var callFunction ;
932
-
933
- if ( / ^ ( p o s t | p u t | p a t c h ) $ / . test ( oper ) ) {
934
- callFunction = function ( operation , elem , path , params , headers ) {
935
- return _ . bind ( customFunction , this ) ( operation , path , params , headers , elem ) ;
936
- } ;
937
- } else {
938
- callFunction = customFunction ;
939
- }
940
- elem [ name ] = _ . bind ( callFunction , elem , callOperation ) ;
936
+ elem [ alias + name . toUpperCase ( ) ] = _ . bind ( requestFunc , elem , callOperation ) ;
941
937
} ) ;
942
938
} ) ;
943
939
elem [ config . restangularFields . customGETLIST ] = _ . bind ( fetchFunction , elem ) ;
0 commit comments