public
Created

Ember.hasMany upgrades.

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Ember.HasManyArray.serialize = function (hasManyArray) {
return hasManyArray.get('content');
};
 
Ember.hasMany = function (klassOrString, key) {
return Ember.computed(function () {
var klass;
 
if (typeof klassOrString === "string") {
klass = Ember.get(Ember.lookup, klassOrString);
} else {
klass = klassOrString;
}
 
return Ember.HasManyArray.create({
parent: this,
modelClass: klass,
content: get(this, 'data.' + key)
});
}).property().meta({ isAttribute: true, type: Ember.HasManyArray });
};

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.