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

Route

Inline without mapping

export default Route.extend({

  model: route().inline({

    prepare(route, params) {
    },

    async load() {
    }

  })

});

Inline with mixins

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

export default Route.extend({

  model: route().inline(RandomMixin, {

    prepare(route, params) {
    },

    async load() {
    }

  })

});

Inline with mapping

export default Route.extend({

  model: route().inline({

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

    async load() {
    }

  }).mapping((route, params) => ({
    sources: route.modelFor('sources'),
    id: params.source_id
  }))

});

Looked up from route name

// route/sources/source.js
export default Route.extend({

  model: model().mapping((route, params) => ({
    sources: route.modelFor('sources'),
    id: params.source_id
  }))

});
// models/route/sources/source.js
export default EmberObject.extend({

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

  async load() {
  }

});

Provided name

export default Route.extend({

  model: model().named('route/source').mapping((route, params) => ({
    sources: route.modelFor('sources'),
    id: params.source_id
  }))

});
// models/route/sources.js
export default EmberObject.extend({

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

  async load() {
  }

});

Draft

* route()
* inline(...args)
* named(arg)
* *mapping(arg)