Skip to content

Instantly share code, notes, and snippets.

@nummi
Last active December 18, 2015 12:48
Show Gist options
  • Select an option

  • Save nummi/5785054 to your computer and use it in GitHub Desktop.

Select an option

Save nummi/5785054 to your computer and use it in GitHub Desktop.
App.Order = DS.Model.extend({
items: DS.hasMany('App.OrderItems'),
orderTotal: function() {
return this.get('items')
.reduce(function(previousValue, item, index) {
return item.get('price') + previousValue;
}, 0);
}.property('items', 'items.@each', 'items.@each.cost')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment