2020-04-08 17:03:18 +00:00
|
|
|
import Service, { inject as service } from '@ember/service';
|
|
|
|
import { setProperties } from '@ember/object';
|
|
|
|
|
|
|
|
export default Service.extend({
|
|
|
|
settings: service('settings'),
|
|
|
|
intention: service('repository/intention'),
|
|
|
|
prepare: function(sink, data, instance) {
|
2020-05-01 08:49:33 +00:00
|
|
|
return setProperties(instance, data);
|
2020-04-08 17:03:18 +00:00
|
|
|
},
|
|
|
|
persist: function(sink, instance) {
|
2020-07-09 09:08:47 +00:00
|
|
|
const [, , , model] = sink.split('/');
|
2020-04-08 17:03:18 +00:00
|
|
|
const repo = this[model];
|
|
|
|
return repo.persist(instance);
|
|
|
|
},
|
|
|
|
remove: function(sink, instance) {
|
2020-07-09 09:08:47 +00:00
|
|
|
const [, , , model] = sink.split('/');
|
2020-04-08 17:03:18 +00:00
|
|
|
const repo = this[model];
|
|
|
|
return repo.remove(instance);
|
|
|
|
},
|
|
|
|
});
|