API Docs for: 0.2.1
Show:

ApplicationSerializer Class

Serializer/Deserializer for a JSON API resource object, used by adapter.

When extending use a mixin or define transform methods to serialize and/or deserializer attributes based on the name or the type of attribute.

The methods use a naming convention:

  • '[de]serialize' + 'AttrName' or 'TypeName' + 'Attribute'
  • E.g. use serializeNameAttribute and deserializeNameAttribute in a generated serializer for use with name: attr()
  • Or, redefine serializeDateAttribute and deserializeDateAttribute to use your own data transformation with attr('date') the default, Date type [de]serialize methods transfrom to/from ISO Format.
  • Transform methods based on the name of the attribute will be called instead of any transform methods based on the type of the attribute.

Methods

_createResourceInstance

(
  • json
)
private

Create a Resource from a JSON API Resource Object

See http://jsonapi.org/format/#document-resource-objects

Parameters:

  • json Object

Returns:

(Resource) instance

_intersection

(
  • first
  • second
)
Array private

Parameters:

  • first Array
  • second Array

Returns:

Array:

_lookupFactory

(
  • type
)
Function private

Parameters:

  • type String

Returns:

Function:

factory for creating resource instances

deserialize

(
  • json
)
Ember.Array | Resource

Deserialize response objects from the request payload

Parameters:

  • json Object
    • response object, extract resource(s)

Returns:

Ember.Array | Resource:

deserializeIncluded

(
  • related
  • resp
)

Deserialize optional included array of payload and add to service cache

Parameters:

  • related Array
  • resp Object

    (optional) e.g. headers, meta, etc.

deserializeResource

(
  • json
)
Resource

Deserialize response an object in the payload data

Parameters:

  • json Object

Returns:

deserializeResources

(
  • collection
)
Object | Ember.Array

Deserialize response objects in the payload data

Parameters:

  • collection Array

Returns:

Object | Ember.Array:

serialize

(
  • resource
)
Object | Array

Serialize resource for the request payload

Parameters:

  • resource Resource | Array
    • object to serialize

Returns:

Object | Array:

serializeChanged

(
  • object
)
Object

Serialize a resource object, but only the changed attributes

Parameters:

Returns:

Object:

serializeRelationship

(
  • resource
  • relationship
  • id
)
Object

Parameters:

  • resource Resource

    instance, has URLs via it's relationships property

  • relationship String

    name

  • id String | Undefined

    (optional) of the related resource

Returns:

Object:

payload

serializeRelationships

(
  • resource
  • relationships
)
Object

Parameters:

  • resource Resource

    with relationships to serialize

  • relationships Array

    list of {String} relationship properties

Returns:

Object:

the serialized relationship node for the JSON payload

serializeResource

(
  • object
)
Object

Serialize a resource object

Parameters:

Returns:

Object:

serializeResources

(
  • collection
)
Array

Parameters:

  • collection Array

Returns:

Array:

transformAttributes

(
  • json
  • [operation='deserialize']
)
Object

Transform attributes, serialize or deserialize by specified method or per type of attribute, e.g. date.

Your serializer may define a specific method for a type of attribute, i.e. serializeDateAttribute and/or deserializeDateAttribute. Likewise, your serializer may define a specific method for the name of an attribute, like serializeUpdatedAtAttribute and deserializeUpdatedAtAttribute.

During transformation a method based on the name of the attribute takes priority over a transform method based on the type of attribute, e.g. date.

Parameters:

  • json Object

    with attributes hash of resource properties to be transformed

  • [operation='deserialize'] String optional

    perform a serialize or deserialize operation, the default operation is to deserialize when not passed

Returns:

Object:

json