kai-jacobsen/kontentblocks

View on GitHub
js/src/fieldsAPI/FieldsAPICollection.js

Summary

Maintainability
A
0 mins
Test Coverage
module.exports =
{
  fields: {},
  register: function (obj) {
    var id = obj.prototype.type;
    this.fields[id] = obj;
  },
  get: function (field) {
    return new this.fields[field.model.get('type')]({model: new Backbone.Model(field.model.toJSON())});
  },
  getRefByType: function(type, data){
    return new this.fields[type]({model: new Backbone.Model(data)});
  }
};