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

Function RestangularResource

src/restangular.js:548–581  ·  view source on GitHub ↗
(config, $http, url, configurer)

Source from the content-addressed store, hash-verified

546 };
547
548 function RestangularResource(config, $http, url, configurer) {
549 var resource = {};
550 _.each(_.keys(configurer), function(key) {
551 var value = configurer[key];
552
553 // Add default parameters
554 value.params = _.extend({}, value.params, config.defaultRequestParams[value.method.toLowerCase()]);
555 // We don't want the ? if no params are there
556 if (_.isEmpty(value.params)) {
557 delete value.params;
558 }
559
560 if (config.isSafe(value.method)) {
561
562 resource[key] = function() {
563 return $http(_.extend(value, {
564 url: url
565 }));
566 };
567
568 } else {
569
570 resource[key] = function(data) {
571 return $http(_.extend(value, {
572 url: url,
573 data: data
574 }));
575 };
576
577 }
578 });
579
580 return resource;
581 }
582
583 BaseCreator.prototype.resource = function(current, $http, localHttpConfig, callHeaders, callParams, what, etag, operation) {
584

Callers 1

restangular.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected