All files / src/model index.js

66.67% Statements 8/12
75% Branches 3/4
40% Functions 2/5
72.73% Lines 8/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26            31x   31x 31x 31x 9x   31x     31x 31x                
import ModelActions from './ModelActions'
import modelSelectors from './modelSelectors'
import List from '../list'
 
export default class Model {
  constructor(model, config, apiAdapter, requestAdapter) {
    model.apiPath = model.apiPath ? config.basePath + model.apiPath : config.basePath + '/' + model.modelName
 
    this.modelName = model.modelName
    this.config = config
    this.actions = (routeParams) => {
      return new ModelActions(model, config, routeParams, apiAdapter, requestAdapter)
    }
    this.selectors = (routeParams) => {
      return modelSelectors(model, routeParams, config.rootSelector)
    }
    this.lists = {}
    Iif(model.lists) {
      model.lists.forEach(list => this.lists[list.name] = this.createList(list))
    }
  }
 
  createList({name, options}) {
    return new List(name, this, options)
  }
}