all files / addon/mixins/ meta-data.js

60% Statements 3/5
100% Branches 0/0
50% Functions 1/2
60% Lines 3/5
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                                           
import Ember from 'ember';
const {Mixin, inject, getOwner} = Ember;
 
export default Mixin.create({
  routeMetadata: inject.service(),
 
  _currentRouteName() {
    let container = getOwner(this);
    return container.lookup('controller:application').get('currentRouteName');
  },
  //TODO: Change editRoute to return updated metaData
  /**
   * Edit the meta of the route
   * @param  {String} route The route name e.g. authenticated.premises
   * @param  {String} key   The key for the value that you wish to change
   * @param  {String} val   New value for metadata
   * @return {Object} metaData
   */
  editMetaData(route, key, val) {
    this.get('routeMetadata').editRoute(route, key, val);
    return this.get('routeMetadata').getMetaDataByRoute(route);
  }
});