Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Ember.String.{pluralize,singularize} with ember-inflector imports #5130

Merged
merged 1 commit into from
Aug 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions addon/-private/adapters/build-url-mixin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Ember from 'ember';
import { pluralize } from 'ember-inflector';

const get = Ember.get;

@@ -420,11 +421,12 @@ export default Ember.Mixin.create({

```app/adapters/application.js
import DS from 'ember-data';
import { pluralize } from 'ember-inflector';

export default DS.RESTAdapter.extend({
pathForType: function(modelName) {
var decamelized = Ember.String.decamelize(modelName);
return Ember.String.pluralize(decamelized);
return pluralize(decamelized);
}
});
```
@@ -435,6 +437,6 @@ export default Ember.Mixin.create({
**/
pathForType(modelName) {
let camelized = Ember.String.camelize(modelName);
return Ember.String.pluralize(camelized);
return pluralize(camelized);
}
});
3 changes: 2 additions & 1 deletion addon/adapters/json-api.js
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
*/

import Ember from 'ember';
import { pluralize } from 'ember-inflector';
import RESTAdapter from "./rest";
import { isEnabled } from '../-private';
import { deprecate } from '@ember/debug';
@@ -258,7 +259,7 @@ const JSONAPIAdapter = RESTAdapter.extend({

pathForType(modelName) {
let dasherized = Ember.String.dasherize(modelName);
return Ember.String.pluralize(dasherized);
return pluralize(dasherized);
},

// TODO: Remove this once we have a better way to override HTTP verbs.
3 changes: 2 additions & 1 deletion addon/serializers/json.js
Original file line number Diff line number Diff line change
@@ -959,6 +959,7 @@ const JSONSerializer = Serializer.extend({

```app/serializers/application.js
import DS from 'ember-data';
import { singularize } from 'ember-inflector';

export default DS.JSONSerializer.extend({
serialize(snapshot, options) {
@@ -987,7 +988,7 @@ const JSONSerializer = Serializer.extend({
}

function serverHasManyName(name) {
return serverAttributeName(name.singularize()) + "_IDS";
return serverAttributeName(singularize(name)) + "_IDS";
}
```

3 changes: 2 additions & 1 deletion tests/integration/adapter/build-url-mixin-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import setupStore from 'dummy/tests/helpers/store';
import Ember from 'ember';
import { pluralize } from 'ember-inflector';
import { isEnabled } from 'ember-data/-private';

import {module, test} from 'qunit';
@@ -184,7 +185,7 @@ test('buildURL - with camelized names', function(assert) {
adapter.setProperties({
pathForType(type) {
let decamelized = Ember.String.decamelize(type);
return Ember.String.underscore(Ember.String.pluralize(decamelized));
return Ember.String.underscore(pluralize(decamelized));
}
});

3 changes: 2 additions & 1 deletion tests/integration/adapter/rest-adapter-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import setupStore from 'dummy/tests/helpers/store';
import Ember from 'ember';
import { singularize } from 'ember-inflector';

import testInDebug from 'dummy/tests/helpers/test-in-debug';
import {module, test} from 'qunit';
@@ -2069,7 +2070,7 @@ test('normalizeKey - to set up _ids and _id', function(assert) {
let underscored = Ember.String.underscore(rel);
return underscored + '_id';
} else {
let singular = Ember.String.singularize(rel);
let singular = singularize(rel);
return Ember.String.underscore(singular) + '_ids';
}
}
5 changes: 3 additions & 2 deletions tests/integration/serializers/rest-serializer-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import setupStore from 'dummy/tests/helpers/store';
import Ember from 'ember';
import { singularize } from 'ember-inflector';

import testInDebug from 'dummy/tests/helpers/test-in-debug';
import {module, test} from 'qunit';
@@ -104,7 +105,7 @@ test("normalizeResponse with custom modelNameFromPayloadKey", function(assert) {

env.restSerializer.modelNameFromPayloadKey = function(root) {
var camelized = Ember.String.camelize(root);
return Ember.String.singularize(camelized);
return singularize(camelized);
};
env.registry.register('serializer:home-planet', DS.JSONSerializer);
env.registry.register('serializer:super-villain', DS.JSONSerializer);
@@ -256,7 +257,7 @@ testInDebug("normalizeResponse warning with custom modelNameFromPayloadKey", fun

// should not warn if a model is found.
env.restSerializer.modelNameFromPayloadKey = function(root) {
return Ember.String.camelize(Ember.String.singularize(root));
return Ember.String.camelize(singularize(root));
};

jsonHash = {