attr = DS.attr
App.ProductOrder = DS.Model.extend
  quantity: attr 'number', defaultValue: 1
  price: attr 'number'
  product_name: attr('string')
  product: DS.belongsTo('product')
  order: DS.belongsTo('order')
  placed: attr('boolean', defaultValue: false) # virtual attribute for new orders to be placed, should be more elegant
  increment: ->
    @set('quantity', @get('quantity') + 1)
  total: (-> @get('quantity') * @get('price')).property('quantity', 'price')
  display: (-> "#{@get('quantity')} x #{@get('product.name')}").property('quantity', 'product.name')
  setOrder: (order)->
    @set('placed', true)
    @set('order', order)
