How to use ember-inflector - 10 common examples

To help you get started, we’ve selected a few ember-inflector examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TryGhost / Ghost-Admin / app / components / gh-mailchimp-settings.js View on Github external
let word = 'hour';

        // display minutes if next sync in < 1 hr
        if (hours < 1) {
            let minutes = Math.round(hours * 60);
            word = 'minute';

            if (minutes === 0) {
                minutes = 1;
            }

            hours = minutes;
        }

        if (hours !== 1) {
            word = pluralize(word);
        }

        // display hours
        return `${Math.round(hours)} ${word}`;
    }),
github funkensturm / ember-local-storage / addon / helpers / import-export.js View on Github external
content.data.forEach((record) => {
      const type = record.type;
      const adapter = store.adapterFor(singularize(type));

      adapter._getIndex(type).forEach((storageKey) => {
        delete get(adapter, '_storage')[storageKey];
      });

      adapter._getIndex(type).reset();

      // unload from store
      store.unloadAll(singularize(type));
    });
  }
github funkensturm / ember-local-storage / addon / helpers / import-export.js View on Github external
const promises = content.data.map((record) => {
    const adapter = store.adapterFor(singularize(record.type));

    // collect types to reload
    reloadTypes.push(singularize(record.type));

    return adapter._handleStorageRequest(null, 'POST', {
      data: {data: record}
    });
  });
github emberobserver / client / app / initializers / inflections.js View on Github external
export function initialize(/* application */) {
  Inflector.inflector.uncountable('github-stats');
}
github NREL / api-umbrella / src / api-umbrella / admin-ui / app / initializers / inflections.js View on Github external
export function initialize() {
  // So the Api model doesn't try to singularize the subSettings hasMany
  // relationship (which leads to it trying to find the non-existent
  // "api/sub-setting" model).
  Inflector.inflector.irregular('sub-settings', 'sub-settings');
}
github cardstack / cardstack / packages / test-support / addon-test-support / test-helpers.js View on Github external
export function getSpaceForCard(type, id) {
  return getContext()
    .owner.lookup('service:store')
    .findRecord('space', `/${pluralize(type)}/${id}`);
}
github Flexberry / ember-flexberry-designer / tests / dummy / app / models / custom-inflector-rules.js View on Github external
import Inflector from 'ember-inflector';

const inflector = Inflector.inflector;

inflector.irregular('configuration', 'Configurations');
inflector.irregular('association', 'Associations');
inflector.irregular('aggregation', 'Aggregations');
inflector.irregular('inheritance', 'Inheritances');
inflector.irregular('generation', 'Generations');
inflector.irregular('definition', 'Definitions');
inflector.irregular('repository', 'Repositorys');
inflector.irregular('subsystem', 'Subsystems');
inflector.irregular('attribute', 'Attributes');
inflector.irregular('following', 'Followings');
inflector.irregular('parameter', 'Parameters');
inflector.irregular('filelink', 'Filelinks');
inflector.irregular('property', 'Propertys');
inflector.irregular('profile', 'Profiles');
inflector.irregular('setting', 'Settings');
github hashicorp / consul / ui / packages / consul-ui / app / services / data-source / protocols / http.js View on Github external
source(src, configuration) {
    const [, , , model] = src.split('/');
    const owner = getOwner(this);
    const route = match(src);
    const find = route.cb(route.params, owner);

    const repo = this[model] || owner.lookup(`service:repository/${singularize(model)}`);
    configuration.createEvent = function(result = {}, configuration) {
      const event = {
        type: 'message',
        data: result,
      };
      const meta = get(event, 'data.meta') || {};
      if (typeof meta.range === 'undefined') {
        repo.reconcile(meta);
      }
      return event;
    };
    return this.type.source(find, configuration);
  }
}
github CenterForOpenScience / ember-osf-web / mirage / views / osf-resource.ts View on Github external
export function osfToManyRelationship(
    server: Server,
    parentModelName: K,
    relationshipName: string & RelationshipsFor,
    options?: Partial,
) {
    const opts: RelationshipOptions = Object.assign({
        path: `/${pluralize(underscore(parentModelName))}/:parentID/relationships/${underscore(relationshipName)}`,
        relatedModelName: relationshipName,
        defaultSortKey: '-id',
    }, options);
    const mirageParentModelName = pluralize(camelize(parentModelName));
    const actions = gatherRelationshipActions(opts);

    if (actions.includes('related')) {
        const relationshipRelatedPath = opts.path.replace('relationships/', '');
        server.get(relationshipRelatedPath, function(schema, request) {
            const data = schema[mirageParentModelName]
                .find(request.params.parentID)[relationshipName]
                .models
                .filter((m: ModelInstance) => filter(m, request))
                .map((model: ModelInstance) => this.serialize(model).data);
            return process(schema, request, this, data, { defaultSortKey: opts.defaultSortKey });
        });
github cardstack / cardstack / packages / routing / addon / services / routing.js View on Github external
routeForNew(type) {
    type = pluralize(type);
    return {
      name: 'cardstack.new-content',
      params: [['type', type]],
    };
  },

ember-inflector

ember-inflector goal is to be rails compatible.

MIT
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis