jeudi 25 décembre 2014

How do I set a dynamic model attribute in the fixture?

As the title describes, I am running into trouble making a dynamic attribute on the Fixture layer.


Here is an example model:



App.Pokeball = DS.Model.extend({
name: DS.attr('string'),
ballRate: DS.attr('number'),
battleAttributes: DS.belongsTo('battleAttributes')
});


And my Fixture:



App.Pokeball.reopenClass({
FIXTURES : [
{
id: 1,
name: 'PokeBall',
ballRate: 1
},
{
id: 23,
name: 'Dusk Ball',
ballRate: function() {
// Some logic that applies only model #23
return 2;
}.property('battleAttributes')
}
]
});


I scoured online trying to find out the right way to do this, but have instead ran into a dead end. :(





Aucun commentaire:

Enregistrer un commentaire