How to use the inflected.dasherize function in inflected

To help you get started, we’ve selected a few inflected 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 cowboyd / mirage-server / lib / orm / associations / association.js View on Github external
constructor(modelName, opts) {
    if (typeof modelName === 'object') {
      // Received opts only
      this.modelName = undefined;
      this.opts = modelName;
    } else {
      // The modelName of the association. (Might not be passed in - set later
      // by schema).
      this.modelName = modelName ? dasherize(modelName) : '';
      this.opts = opts || {};
    }

    // The key pointing to the association
    this.key = '';

    // The modelName that owns this association
    this.ownerModelName = '';
  }
github cowboyd / mirage-server / lib / orm / schema.js View on Github external
registerModel(type, ModelClass) {
    let camelizedModelName = camelize(type);
    let modelName = dasherize(camelizedModelName);

    // Avoid mutating original class, because we may want to reuse it across many tests
    ModelClass = ModelClass.extend();

    // Store model & fks in registry
    // TODO: don't think this is needed anymore
    this._registry[camelizedModelName] = this._registry[camelizedModelName] || { class: null, foreignKeys: [] }; // we may have created this key before, if another model added fks to it
    this._registry[camelizedModelName].class = ModelClass;

    // TODO: set here, remove from model#constructor
    ModelClass.prototype._schema = this;
    ModelClass.prototype.modelName = modelName;
    // Set up associations
    ModelClass.prototype.hasManyAssociations = {};   // a registry of the model's hasMany associations. Key is key from model definition, value is association instance itself
    ModelClass.prototype.belongsToAssociations = {}; // a registry of the model's belongsTo associations. Key is key from model definition, value is association instance itself
    ModelClass.prototype.associationKeys = [];       // ex: address.user, user.addresses
github wowserhq / blizzardry / spec / dbc / entities-spec.js View on Github external
it('exposes ' + name + ' entity', function () {
      var entity = entities[name];
      var filename = inflect.dasherize(inflect.underscore(name));
      expect(entity).to.eq(require('../../lib/dbc/entities/' + filename));
    });
  }
github cowboyd / mirage-server / lib / orm / schema.js View on Github external
first(type) {
    let collection = this._collectionForType(type);
    let [record] = collection;

    return this._hydrate(record, dasherize(type));
  }
github capejs / capejs / lib / cape / markup_builder.js View on Github external
elementIdFor(name) {
    let dasherized

    if (this.main.fieldNamePrefix)
      dasherized = Inflector.dasherize(
        this.main.fieldNamePrefix.replace(/\//g, '-') + '-' + name)
    else
      dasherized = Inflector.dasherize(name)

    if (this.main.formName)
      return this.main.formName + '-field-' + dasherized
    else
      return 'field-' + dasherized
  }
github cowboyd / mirage-server / lib / orm / schema.js View on Github external
findBy(type, query) {
    let collection = this._collectionForType(type);
    let records = collection.findBy(query);

    return this._hydrate(records, dasherize(type));
  }
github capejs / capejs / lib / cape / markup_builder.js View on Github external
elementIdFor(name) {
    let dasherized

    if (this.main.fieldNamePrefix)
      dasherized = Inflector.dasherize(
        this.main.fieldNamePrefix.replace(/\//g, '-') + '-' + name)
    else
      dasherized = Inflector.dasherize(name)

    if (this.main.formName)
      return this.main.formName + '-field-' + dasherized
    else
      return 'field-' + dasherized
  }
github cowboyd / mirage-server / lib / orm / schema.js View on Github external
new(type, attrs) {
    return this._instantiateModel(dasherize(type), attrs);
  }