DS.RESTSerializer#keyForPolymorphicType()

keyForPolymorphicType (key, typeClass, method) String

Defined in addon/serializers/rest.js:60

keyForPolymorphicType can be used to define a custom key when serializing and deserializing a polymorphic type. By default, the returned key is ${key}Type.

Example

app/serializers/post.js
 import DS from 'ember-data';

 export default DS.RESTSerializer.extend({
   keyForPolymorphicType: function(key, relationship) {
     var relationshipKey = this.keyForRelationship(key);

     return 'type-' + relationshipKey;
   }
 });

Parameters:

key String
typeClass String
method String

Returns:

String
normalized key
doc_EmberJs
2016-11-30 16:50:35
Comments
Leave a Comment

Please login to continue.