Sha256: 30dac3b51490c3a3662d94368ecd7b02a34ef54f73c2a4c3058728d26bdc60f7

Contents?: true

Size: 1.06 KB

Versions: 30

Compression:

Stored size: 1.06 KB

Contents

var $, data_for, request;

$ = require('jquery');

module.exports = {
  get: function(data) {
    return request.call(this, 'get', (this._id ? "" + this.route + "/" + this._id : this.route), data);
  },
  put: function(data) {
    return request.call(this, 'put', (this._id ? "" + this.route + "/" + this._id : this.route), data);
  },
  post: function(data) {
    return request.call(this, 'post', this.route, data);
  },
  "delete": function(data) {
    return request.call(this, 'delete', (this._id ? "" + this.route + "/" + this._id : this.route), data);
  }
};

data_for = function(data) {
  var param_name;

  param_name = this.resource.param_name || this.resource.toString();
  if (!data && this.json) {
    data = {};
    data[param_name] = this.json();
  }
  if (data && data[param_name]) {
    delete data[param_name]['id'];
    delete data[param_name]['_id'];
  }
  return data;
};

request = function(method, url, data) {
  data = data_for.call(this, data);
  return $.ajax({
    url: url,
    data: data,
    type: method,
    dataType: 'json',
    context: this
  });
};

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
ende-0.5.22 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.21 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.20 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.19 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.18 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.17 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.16 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.15 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.14 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.13 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.12 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.10 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.9 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.8 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.7 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.6 components/indefinido/indemma/master/lib/record/rest.js
ende-0.4.25 vendor/components/indefinido-indemma/lib/record/rest.js
ende-0.5.5 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.4 components/indefinido/indemma/master/lib/record/rest.js
ende-0.5.3 components/indefinido/indemma/master/lib/record/rest.js