getoutreach/epf — pull request #132 by yaymukund (2014-05-17 22:03:07+00:00)
Title: serializerFor should only override typeKey if it doesn't already exist

== Use Case

I have multiple ways of serializing data because of a legacy API server.

```js
Address = Ep.Model.extend({
street: Ep.attr('string'),
city: Ep.attr('string'),
state: Ep.attr('string')
});

// Legacy API server ships JSON like:
{ matched_addresses: [ {uglyStreet: '...', oldCity: '...', funkyState: '...'} ] };

// Shiny new API server ships what you'd expect:
{ addresses: [ {street: '...', city: '...', state: '...'} ] };

MatchedAddressSerializer = Ep.ModelSerializer.extend({
typeKey: 'address',
deserialize: function(json) {
return this._super({
street: json.uglyStreet,
city: json.oldCity,
state: json.funkyState
});
}
});
```

Right now, this isn't possible because `serializerFor` overwrites `typeKey`. I just added a check.