Skip to content

Commit

Permalink
proper parsing of associations
Browse files Browse the repository at this point in the history
  • Loading branch information
staugaard committed Sep 29, 2011
1 parent 08f7081 commit aa3641e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/sproutcore-resource.js
Expand Up @@ -199,6 +199,7 @@
else {
var instance = this._super.apply(this, arguments);
instance.set('theType', definition.type);
instance.set('parse', definition.parse || definition.type.parse)
return instance;
}
}
Expand Down Expand Up @@ -321,6 +322,7 @@
var instance = this._super.apply(this, arguments);
instance.set('theType', definition.type);
instance.set('theItemType', definition.itemType);
instance.set('parse', definition.parse || definition.type.parse)
return instance;
}
}
Expand All @@ -340,7 +342,7 @@
url: url
};

if (this.parse) options.parse = this.parse;
if (this.get('parse')) options.parse = this.get('parse');

return this.get('type').create(options);
},
Expand Down Expand Up @@ -378,14 +380,14 @@
data = SC.getPath(data, this.get('path'));
if (data === undefined || data === null) return data;

// A ResourceCollection doesn't parse content on creation, only
// when the content is fetched, which doesn't happen here.
data = data.map(this.parse || this.get('itemType').parse);

return this.get('type').create({
var options = {
type: this.get('itemType'),
content: data
});
};

if (this.get('parse')) options.parse = this.get('parse');

return this.get('type').create(options);
},

setValue: function(instance, value) {
Expand Down Expand Up @@ -876,7 +878,7 @@
instance = this._super.call(this, options);

if (content) {
SC.set(instance, 'content', content);
SC.set(instance, 'content', instance.parse(content));
}
}

Expand Down

0 comments on commit aa3641e

Please sign in to comment.