How to use the inflection.underscore function in inflection

To help you get started, we’ve selected a few inflection 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 kieran / barista / lib / resource.js View on Github external
var Resource = exports.Resource = function( base, controller ){

  var controller_slug = inflection.underscore(inflection.pluralize(controller))

  this.routes = []

  // set up the actual routes for the resource
  this.routes.push(
    this.collection_route =
    base.get('/'+controller_slug+'(.:format)', 'GET').to(controller+'.index')
  , base.post('/'+controller_slug+'(.:format)', 'POST').to(controller+'.create')
  , base.get('/'+controller_slug+'/add(.:format)', 'GET').to(controller+'.add')
  , this.member_route =
    base.get('/'+controller_slug+'/:id(.:format)', 'GET').to(controller+'.show')
  , base.get('/'+controller_slug+'/:id/edit(.:format)', 'GET').to(controller+'.edit')
  , base.put('/'+controller_slug+'/:id(.:format)', 'PUT').to(controller+'.update')
  , base.del('/'+controller_slug+'/:id(.:format)', 'DELETE').to(controller+'.destroy')
  )
  this.collection_route.collection = true
github ozum / sequelize-pg-generator / lib / index.js View on Github external
function getColumnDetails(column) {
    logger.debug('column details are calculated for: %s', column.name());
    var result = filterAttributes({
        source              : 'generator',
        accessorName        : getSpecificConfig(column.table().name(), 'generate.columnAccessorCamelCase') ? inflection.camelize(inflection.underscore(column.name()), true) : column.name(),
        name                : column.name(),
        primaryKey          : column.isPrimaryKey(),
        autoIncrement       : column.isAutoIncrement() && getSpecificConfig(column.table().name(), 'generate.columnAutoIncrement') ? true : undefined,
        allowNull           : column.allowNull(),
        defaultValue        : getSpecificConfig(column.table().name(), 'generate.columnDefault') && column.default() !== null ? clearDefaultValue(column.default()) : undefined,
        unique              : column.unique(),
        comment             : getSpecificConfig(column.table().name(), 'generate.columnDescription') ? column.description() : undefined,
        references          : column.foreignKeyConstraint() ? getModelNameFor(column.foreignKeyConstraint().referencesTable()) : undefined,
        referencesKey       : column.foreignKeyConstraint() ? column.foreignKeyConstraint().foreignKey(0).name() : undefined,
        onUpdate            : column.onUpdate(),
        onDelete            : column.onDelete()
    });

    result.type = sequelizeType(column, getSpecificConfig(column.table().name(), 'generate.dataTypeVariable')); // To prevent type having quotes.
    //result.type = column.sequelizeType(getSpecificConfig(column.table().name(), 'generate.dataTypeVariable')); // To prevent type having quotes.
    return result;
github kaspernj / api_maker / npm-api-maker-bootstrap / src / checkboxes.jsx View on Github external
inputName() {
    if (this.props.name) {
      return `${this.props.name}[]`
    } else if (this.props.model) {
      return `${this.props.model.modelClassData().paramKey}[${inflection.underscore(this.props.attribute)}]`
    }
  }
github kaspernj / api_maker / ruby-gem / spec / dummy / app / javascript / api-maker / collection.js View on Github external
selectColumns(originalSelect) {
    const newSelect = {}

    for(const originalModelName in originalSelect) {
      const newModelName = inflection.dasherize(inflection.underscore(originalModelName))
      const newValues = []
      const originalValues = originalSelect[originalModelName]

      for(const originalAttributeName of originalValues) {
        const newAttributeName = inflection.underscore(originalAttributeName)
        newValues.push(newAttributeName)
      }

      newSelect[newModelName] = newValues
    }

    return this._clone({selectColumns: newSelect})
  }
github sequelize / sequelize / lib / utils.js View on Github external
function underscore(str) {
  return inflection.underscore(str);
}
exports.underscore = underscore;
github kaspernj / api_maker / npm-api-maker-bootstrap / src / radio-buttons.jsx View on Github external
inputName() {
    if (this.props.name) {
      return this.props.name
    } else if (this.props.model) {
      return `${this.props.model.modelClassData().paramKey}[${inflection.underscore(this.props.attribute)}]`
    }
  }
github dalinhuang99 / betify / node_modules / sequelize / lib / utils.js View on Github external
function underscore(str) {
  return inflection.underscore(str);
}
exports.underscore = underscore;
github kaspernj / api_maker / ruby-gem / spec / dummy / app / javascript / api-maker / collection.js View on Github external
params() {
    let params = {}

    if (this.queryArgs.params) params = this._merge(params, this.queryArgs.params)
    if (this.queryArgs.abilities) params.abilities = this.queryArgs.abilities
    if (this.queryArgs.accessibleBy) params.accessible_by = inflection.underscore(this.queryArgs.accessibleBy)
    if (this.queryArgs.count) params.count = this.queryArgs.count
    if (this.queryArgs.distinct) params.distinct = this.queryArgs.distinct
    if (this.queryArgs.groupBy) params.group_by = this.queryArgs.groupBy
    if (this.queryArgs.ransack) params.q = this.queryArgs.ransack
    if (this.queryArgs.limit) params.limit = this.queryArgs.limit
    if (this.queryArgs.preload) params.preload = this.queryArgs.preload
    if (this.queryArgs.page) params.page = this.queryArgs.page
    if (this.queryArgs.per) params.per = this.queryArgs.per
    if (this.queryArgs.select) params.select = this.queryArgs.select
    if (this.queryArgs.selectColumns) params.select_columns = this.queryArgs.selectColumns

    return params
  }