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

Backport ember-inflector imports #5152

Merged
merged 2 commits into from
Aug 25, 2017
Merged
Show file tree
Hide file tree
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;

Expand Down Expand Up @@ -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);
}
});
```
Expand All @@ -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
Expand Up @@ -4,6 +4,7 @@
*/

import Ember from 'ember';
import { pluralize } from 'ember-inflector';
import RESTAdapter from "./rest";
import { isEnabled } from '../-private';
import { instrument, deprecate } from 'ember-data/-debug';
Expand Down Expand Up @@ -257,7 +258,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.
Expand Down
3 changes: 2 additions & 1 deletion addon/serializers/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -987,7 +988,7 @@ const JSONSerializer = Serializer.extend({
}

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

Expand Down
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';
Expand Down Expand Up @@ -183,7 +184,7 @@ test('buildURL - with camelized names', function(assert) {
adapter.setProperties({
pathForType(type) {
var decamelized = Ember.String.decamelize(type);
return Ember.String.underscore(Ember.String.pluralize(decamelized));
return Ember.String.underscore(pluralize(decamelized));
}
});

Expand Down
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';
Expand Down Expand Up @@ -2087,7 +2088,7 @@ test('normalizeKey - to set up _ids and _id', function(assert) {
var underscored = Ember.String.underscore(rel);
return underscored + '_id';
} else {
var singular = Ember.String.singularize(rel);
var singular = singularize(rel);
return Ember.String.underscore(singular) + '_ids';
}
}
Expand Down
7 changes: 4 additions & 3 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 Inflector, { singularize } from 'ember-inflector';

import testInDebug from 'dummy/tests/helpers/test-in-debug';
import {module, test} from 'qunit';
Expand Down Expand Up @@ -74,7 +75,7 @@ module("integration/serializer/rest - RESTSerializer", {

test("modelNameFromPayloadKey returns always same modelName even for uncountable multi words keys", function(assert) {
assert.expect(2);
Ember.Inflector.inflector.uncountable('words');
Inflector.inflector.uncountable('words');
var expectedModelName = 'multi-words';
assert.equal(env.restSerializer.modelNameFromPayloadKey('multi_words'), expectedModelName);
assert.equal(env.restSerializer.modelNameFromPayloadKey('multi-words'), expectedModelName);
Expand Down Expand Up @@ -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);
};

var jsonHash = {
Expand Down Expand Up @@ -250,7 +251,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 = {
Expand Down