import { model } from 'ember-cli-zuglet/lifecycle';

Model

Inline

export default Component.extend({

  model: model().owner('path').inline({

    prepare(owner) {
    }

  })

});

Inline with mixins

import RandomMixin from './-random-mixin';

export default Component.extend({

  model: model().owner('path').inline(RandomMixin, {

    prepare(owner) {
    }

  })

});

Inline with mapping

export default Component.extend({

  model: model().owner('path').inline({

    prepare({ path }) {
      this.setProperties(arguments[0]); // default if prepare() is not provided
    }

  }).mapping(owner => ({
    path: owner.path
  }))

});
  • if mapping returns falsey value, model is not created

Provided name

export default Component.extend({

  model: model().owner('path').named('document-by-path').mapping(owner => ({
    path: owner.path
  }))

});

Resolved name

export default Component.extend({

  type: 'book',

  model: model().owner('type', 'path').named(owner => {
    let type = owner.type;
    if(!type) {
      return;
    }
    return `document/${type}`;
  }).mapping(owner => ({ path: owner.path }))

});
// models/document/book.ks

export default EmberObject.extend({

  prepare({ path }) {
    this.setProperties(arguments[0]); // default if prepare() is not provided
  }

})

Draft

* model()
* owner(...args)
* inline(...args)
* named(arg)
* mapping(arg)