MCPcopy
hub / github.com/mgonto/restangular / addCustomOperation

Function addCustomOperation

src/restangular.js:978–997  ·  view source on GitHub ↗
(elem)

Source from the content-addressed store, hash-verified

976 }
977
978 function addCustomOperation(elem) {
979 elem[config.restangularFields.customOperation] = _.bind(customFunction, elem);
980 var requestMethods = {
981 get: customFunction,
982 delete: customFunction
983 };
984 _.each(['put', 'patch', 'post'], function(name) {
985 requestMethods[name] = function(operation, elem, path, params, headers) {
986 return _.bind(customFunction, this)(operation, path, params, headers, elem);
987 };
988 });
989 _.each(requestMethods, function(requestFunc, name) {
990 var callOperation = name === 'delete' ? 'remove' : name;
991 _.each(['do', 'custom'], function(alias) {
992 elem[alias + name.toUpperCase()] = _.bind(requestFunc, elem, callOperation);
993 });
994 });
995 elem[config.restangularFields.customGETLIST] = _.bind(fetchFunction, elem);
996 elem[config.restangularFields.doGETLIST] = elem[config.restangularFields.customGETLIST];
997 }
998
999 function copyRestangularizedElement(element) {
1000 var copiedElement = angular.copy(element);

Callers 2

restangularizeElemFunction · 0.85
restangularizeCollectionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected