Class: ShopLineItem
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ShopLineItem
- Defined in:
- app/models/shop_line_item.rb
Class Method Summary collapse
-
.attrs ⇒ Object
Returns attributes attached to the product.
-
.methds ⇒ Object
Returns methods with usefuly information.
-
.params ⇒ Object
Returns a custom hash of attributes on the product.
Instance Method Summary collapse
- #price ⇒ Object
-
#to_json(*attrs) ⇒ Object
Overloads the base to_json to return what we want.
- #weight ⇒ Object
Class Method Details
.attrs ⇒ Object
Returns attributes attached to the product
30 31 32 |
# File 'app/models/shop_line_item.rb', line 30 def attrs [ :id, :quantity ] end |
.methds ⇒ Object
Returns methods with usefuly information
35 36 37 |
# File 'app/models/shop_line_item.rb', line 35 def methds [ :price, :weight ] end |
.params ⇒ Object
Returns a custom hash of attributes on the product
40 41 42 |
# File 'app/models/shop_line_item.rb', line 40 def params { :only => attrs, :methods => methds } end |
Instance Method Details
#price ⇒ Object
15 16 17 |
# File 'app/models/shop_line_item.rb', line 15 def price (item_price.to_f * self.quantity).to_f end |
#to_json(*attrs) ⇒ Object
Overloads the base to_json to return what we want
25 |
# File 'app/models/shop_line_item.rb', line 25 def to_json(*attrs); super self.class.params; end |
#weight ⇒ Object
19 20 21 22 |
# File 'app/models/shop_line_item.rb', line 19 def weight warn 'Not yet fully implemented' (item.weight.to_f * self.quantity.to_f).to_f end |