Skip to content

Commit

Permalink
add method param to keyForAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
agrobbin committed Apr 4, 2015
1 parent ddf658e commit c819aa8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ var ActiveModelSerializer = RESTSerializer.extend({
type.eachRelationship(function(key, relationship) {
var payloadKey, payload;
if (relationship.options.polymorphic) {
payloadKey = this.keyForAttribute(key);
payloadKey = this.keyForAttribute(key, "deserialize");
payload = hash[payloadKey];
if (payload && payload.type) {
payload.type = this.typeForRoot(payload.type);
Expand Down
6 changes: 3 additions & 3 deletions packages/ember-data/lib/serializers/embedded-records-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var EmbeddedRecordsMixin = Ember.Mixin.create({

keyForRelationship: function(key, type, method) {
if ((method === 'serialize' && this.hasSerializeRecordsOption(key)) || (method === 'deserialize' && this.hasDeserializeRecordsOption(key))) {
return this.keyForAttribute(key);
return this.keyForAttribute(key, method);
} else {
return this._super(key, type, method) || key;
}
Expand Down Expand Up @@ -198,7 +198,7 @@ var EmbeddedRecordsMixin = Ember.Mixin.create({
json[key] = embeddedSnapshot.id;
}
} else if (includeRecords) {
key = this.keyForAttribute(attr);
key = this.keyForAttribute(attr, 'serialize');
if (!embeddedSnapshot) {
json[key] = null;
} else {
Expand Down Expand Up @@ -302,7 +302,7 @@ var EmbeddedRecordsMixin = Ember.Mixin.create({
key = this.keyForRelationship(attr, relationship.kind, 'serialize');
json[key] = snapshot.hasMany(attr, { ids: true });
} else if (includeRecords) {
key = this.keyForAttribute(attr);
key = this.keyForAttribute(attr, 'serialize');
json[key] = snapshot.hasMany(attr).map(function(embeddedSnapshot) {
var embeddedJson = embeddedSnapshot.record.serialize({ includeId: true });
this.removeEmbeddedForeignKey(snapshot, embeddedSnapshot, relationship, embeddedJson);
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-data/lib/serializers/json-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export default Serializer.extend({

if (this.keyForAttribute) {
type.eachAttribute(function(key) {
payloadKey = this.keyForAttribute(key);
payloadKey = this.keyForAttribute(key, 'deserialize');
if (key === payloadKey) { return; }
if (!hash.hasOwnProperty(payloadKey)) { return; }

Expand Down
2 changes: 1 addition & 1 deletion packages/ember-data/lib/serializers/rest-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ var RESTSerializer = JSONSerializer.extend({
serializePolymorphicType: function(snapshot, json, relationship) {
var key = relationship.key;
var belongsTo = snapshot.belongsTo(key);
key = this.keyForAttribute ? this.keyForAttribute(key) : key;
key = this.keyForAttribute ? this.keyForAttribute(key, "serialize") : key;
if (Ember.isNone(belongsTo)) {
json[key + "Type"] = null;
} else {
Expand Down

0 comments on commit c819aa8

Please sign in to comment.