Skip to content

Commit

Permalink
Merge pull request #5290 from bmac/should-serialize-has-many
Browse files Browse the repository at this point in the history
Remove deprecation around shouldSerializeHasMany
  • Loading branch information
rwjblue authored Dec 19, 2017
2 parents ec4847a + 8173a03 commit 79ee129
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 43 deletions.
6 changes: 1 addition & 5 deletions addon/serializers/json-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,12 +597,8 @@ const JSONAPISerializer = JSONSerializer.extend({

serializeHasMany(snapshot, json, relationship) {
let key = relationship.key;
let shouldSerializeHasMany = '_shouldSerializeHasMany';
if (isEnabled("ds-check-should-serialize-relationships")) {
shouldSerializeHasMany = 'shouldSerializeHasMany';
}

if (this[shouldSerializeHasMany](snapshot, key, relationship)) {
if (this.shouldSerializeHasMany(snapshot, key, relationship)) {
let hasMany = snapshot.hasMany(key);
if (hasMany !== undefined) {

Expand Down
28 changes: 1 addition & 27 deletions addon/serializers/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,29 +846,7 @@ const JSONSerializer = Serializer.extend({
@param {String} relationshipType
@return {boolean} true if the hasMany relationship should be serialized
*/

shouldSerializeHasMany(snapshot, key, relationship) {
if ((this._shouldSerializeHasMany !== JSONSerializer.prototype._shouldSerializeHasMany)) {
deprecate('The private method _shouldSerializeHasMany has been promoted to the public API. Please remove the underscore to use the public shouldSerializeHasMany method.', false, {
id: 'ds.serializer.private-should-serialize-has-many',
until: '3.0.0'
});
}

return this._shouldSerializeHasMany(snapshot, key, relationship);
},

/**
Check if the given hasMany relationship should be serialized
@method _shouldSerializeHasMany
@private
@param {DS.Snapshot} snapshot
@param {String} key
@param {String} relationshipType
@return {boolean} true if the hasMany relationship should be serialized
*/
_shouldSerializeHasMany(snapshot, key, relationship) {
let relationshipType = snapshot.type.determineRelationshipType(relationship, this.store);
if (this._mustSerialize(key)) {
return true;
Expand Down Expand Up @@ -1219,12 +1197,8 @@ const JSONSerializer = Serializer.extend({
*/
serializeHasMany(snapshot, json, relationship) {
let key = relationship.key;
let shouldSerializeHasMany = '_shouldSerializeHasMany';
if (isEnabled("ds-check-should-serialize-relationships")) {
shouldSerializeHasMany = 'shouldSerializeHasMany';
}

if (this[shouldSerializeHasMany](snapshot, key, relationship)) {
if (this.shouldSerializeHasMany(snapshot, key, relationship)) {
let hasMany = snapshot.hasMany(key, { ids: true });
if (hasMany !== undefined) {
// if provided, use the mapping provided by `attrs` in
Expand Down
1 change: 0 additions & 1 deletion config/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"ds-pushpayload-return": null,
"ds-overhaul-references": null,
"ds-payload-type-hooks": null,
"ds-check-should-serialize-relationships": true,
"ds-rollback-attribute": null,
"ds-serialize-id": null,
"ds-deprecate-store-serialize": true
Expand Down
10 changes: 0 additions & 10 deletions tests/integration/serializers/json-serializer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,6 @@ test("shouldSerializeHasMany", function(assert) {
assert.ok(shouldSerialize, 'shouldSerializeHasMany correctly identifies with hasMany relationship');
});

if (isEnabled("ds-check-should-serialize-relationships")) {
testInDebug("_shouldSerializeHasMany deprecation", function(assert) {
env.store.serializerFor("post")._shouldSerializeHasMany = function() {};

assert.expectDeprecation(function() {
env.store.serializerFor("post").shouldSerializeHasMany();
}, /_shouldSerializeHasMany has been promoted to the public API/);
});
}

test("serializeIntoHash", function(assert) {
run(() => {
post = env.store.createRecord('post', { title: "Rails is omakase", comments: [] });
Expand Down

0 comments on commit 79ee129

Please sign in to comment.