discourse/app/assets/javascripts/discourse/models/model.js.es6
2016-07-11 12:57:05 -04:00

16 lines
314 B
JavaScript

const Model = Ember.Object.extend();
Model.reopenClass({
extractByKey(collection, klass) {
const retval = {};
if (Ember.isEmpty(collection)) { return retval; }
collection.forEach(function(item) {
retval[item.id] = klass.create(item);
});
return retval;
}
});
export default Model;