This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/models/rest.js.es6

21 lines
517 B
JavaScript

export default Ember.Object.extend({
update(attrs) {
const self = this,
type = this.get('__type');
return this.store.update(type, this.get('id'), attrs).then(function(result) {
if (result && result[type]) {
Object.keys(result).forEach(function(k) {
attrs[k] = result[k];
});
}
self.setProperties(attrs);
return result;
});
},
destroyRecord() {
const type = this.get('__type');
return this.store.destroyRecord(type, this);
}
});