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'),
|
2020-07-20 17:04:43 +00:00
|
|
|
kv: service('repository/kv'),
|
2020-07-17 13:42:45 +00:00
|
|
|
session: service('repository/session'),
|
2020-04-08 17:03:18 +00:00
|
|
|
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);
|
|
|
|
},
|
|
|
|
});
|