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

Function copyRestangularizedElement

src/restangular.js:999–1024  ·  view source on GitHub ↗
(element)

Source from the content-addressed store, hash-verified

997 }
998
999 function copyRestangularizedElement(element) {
1000 var copiedElement = angular.copy(element);
1001
1002 // check if we're dealing with a collection (i.e. an array)
1003 // and restangularize the element using the proper restangularizer,
1004 // element / collection
1005 if (_.isArray(element)) {
1006 return restangularizeCollection(
1007 element[config.restangularFields.parentResource],
1008 copiedElement,
1009 element[config.restangularFields.route],
1010 element[config.restangularFields.fromServer],
1011 element[config.restangularFields.reqParams]
1012 );
1013 }
1014
1015 // not a collection, restangularize it as an element
1016 return restangularizeElem(
1017 element[config.restangularFields.parentResource],
1018 copiedElement,
1019 element[config.restangularFields.route],
1020 element[config.restangularFields.fromServer],
1021 element[config.restangularFields.restangularCollection],
1022 element[config.restangularFields.reqParams]
1023 );
1024 }
1025
1026 function restangularizeElem(parent, element, route, fromServer, collection, reqParams) {
1027 var elem = config.onBeforeElemRestangularized(element, false, route);

Callers 1

putElementFunctionFunction · 0.85

Calls 2

restangularizeCollectionFunction · 0.85
restangularizeElemFunction · 0.85

Tested by

no test coverage detected