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

Update the API docs on the JSONAPISerializer #4653

Merged
merged 1 commit into from
Nov 21, 2016
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
59 changes: 11 additions & 48 deletions addon/serializers/json-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,6 @@ const JSONAPISerializer = JSONSerializer.extend({
return normalized;
},

/**
@method extractAttributes
@param {DS.Model} modelClass
@param {Object} resourceHash
@return {Object}
*/
extractAttributes(modelClass, resourceHash) {
var attributes = {};

Expand All @@ -309,11 +303,6 @@ const JSONAPISerializer = JSONSerializer.extend({
return attributes;
},

/**
@method extractRelationship
@param {Object} relationshipHash
@return {Object}
*/
extractRelationship(relationshipHash) {

if (Ember.typeOf(relationshipHash.data) === 'object') {
Expand All @@ -334,12 +323,6 @@ const JSONAPISerializer = JSONSerializer.extend({
return relationshipHash;
},

/**
@method extractRelationships
@param {Object} modelClass
@param {Object} resourceHash
@return {Object}
*/
extractRelationships(modelClass, resourceHash) {
let relationships = {};

Expand Down Expand Up @@ -391,6 +374,12 @@ const JSONAPISerializer = JSONSerializer.extend({
},

/**
Dasherizes and singularizes the model name in the payload to match
the format Ember Data uses internally for the model name.

For example the key `posts` would be converted to `post` and the
key `studentAssesments` would be converted to `student-assesment`.

@method modelNameFromPayloadKey
@param {String} key
@return {String} the model's modelName
Expand All @@ -401,6 +390,11 @@ const JSONAPISerializer = JSONSerializer.extend({
},

/**
Converts the model name to a pluralized version of the model name.

For example `post` would be converted to `posts` and
`student-assesment` would be converted to `student-assesments`.

@method payloadKeyFromModelName
@param {String} modelName
@return {String}
Expand All @@ -410,12 +404,6 @@ const JSONAPISerializer = JSONSerializer.extend({
return pluralize(modelName);
},

/**
@method normalize
@param {DS.Model} modelClass
@param {Object} resourceHash the resource hash from the adapter
@return {Object} the normalized resource hash
*/
normalize(modelClass, resourceHash) {
if (resourceHash.attributes) {
this.normalizeUsingDeclaredMapping(modelClass, resourceHash.attributes);
Expand Down Expand Up @@ -497,12 +485,6 @@ const JSONAPISerializer = JSONSerializer.extend({
return dasherize(key);
},

/**
@method serialize
@param {DS.Snapshot} snapshot
@param {Object} options
@return {Object} json
*/
serialize(snapshot, options) {
let data = this._super(...arguments);

Expand All @@ -527,13 +509,6 @@ const JSONAPISerializer = JSONSerializer.extend({
return { data };
},

/**
@method serializeAttribute
@param {DS.Snapshot} snapshot
@param {Object} json
@param {String} key
@param {Object} attribute
*/
serializeAttribute(snapshot, json, key, attribute) {
const type = attribute.type;

Expand All @@ -556,12 +531,6 @@ const JSONAPISerializer = JSONSerializer.extend({
}
},

/**
@method serializeBelongsTo
@param {DS.Snapshot} snapshot
@param {Object} json
@param {Object} relationship
*/
serializeBelongsTo(snapshot, json, relationship) {
var key = relationship.key;

Expand Down Expand Up @@ -607,12 +576,6 @@ const JSONAPISerializer = JSONSerializer.extend({
}
},

/**
@method serializeHasMany
@param {DS.Snapshot} snapshot
@param {Object} json
@param {Object} relationship
*/
serializeHasMany(snapshot, json, relationship) {
var key = relationship.key;
var shouldSerializeHasMany = '_shouldSerializeHasMany';
Expand Down