Module: Stall::Models::ProductList
- Extended by:
- ActiveSupport::Concern
- Included in:
- ProductList
- Defined in:
- app/models/stall/models/product_list.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #active? ⇒ Boolean
- #checkoutable? ⇒ Boolean
- #eot_subtotal ⇒ Object
- #reset_state! ⇒ Object
- #state ⇒ Object
- #subtotal ⇒ Object
- #to_param ⇒ Object
- #total_eot_price ⇒ Object
- #total_price ⇒ Object
- #total_quantity ⇒ Object
- #total_vat ⇒ Object
- #wizard ⇒ Object
Instance Method Details
#active? ⇒ Boolean
89 90 91 |
# File 'app/models/stall/models/product_list.rb', line 89 def active? true end |
#checkoutable? ⇒ Boolean
85 86 87 |
# File 'app/models/stall/models/product_list.rb', line 85 def checkoutable? line_items.length > 0 end |
#eot_subtotal ⇒ Object
59 60 61 |
# File 'app/models/stall/models/product_list.rb', line 59 def eot_subtotal line_items.map(&:eot_price).sum end |
#reset_state! ⇒ Object
44 45 46 47 |
# File 'app/models/stall/models/product_list.rb', line 44 def reset_state! self.state = wizard.steps.first save(validate: false) if persisted? end |
#state ⇒ Object
40 41 42 |
# File 'app/models/stall/models/product_list.rb', line 40 def state read_attribute(:state).try(:to_sym) end |
#subtotal ⇒ Object
53 54 55 56 57 |
# File 'app/models/stall/models/product_list.rb', line 53 def subtotal price = line_items.map(&:price).sum price = Money.new(price, currency) unless Money === price price end |
#to_param ⇒ Object
49 50 51 |
# File 'app/models/stall/models/product_list.rb', line 49 def to_param persisted? ? token : 'empty-cart' end |
#total_eot_price ⇒ Object
69 70 71 |
# File 'app/models/stall/models/product_list.rb', line 69 def total_eot_price items.map(&:eot_price).sum end |
#total_price ⇒ Object
63 64 65 66 67 |
# File 'app/models/stall/models/product_list.rb', line 63 def total_price price = items.map(&:price).sum price = Money.new(price, currency) unless Money === price price end |
#total_quantity ⇒ Object
77 78 79 |
# File 'app/models/stall/models/product_list.rb', line 77 def total_quantity line_items.map(&:quantity).sum end |
#total_vat ⇒ Object
73 74 75 |
# File 'app/models/stall/models/product_list.rb', line 73 def total_vat items.map(&:vat).sum end |
#wizard ⇒ Object
81 82 83 |
# File 'app/models/stall/models/product_list.rb', line 81 def wizard @wizard ||= self.class.wizard end |