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
88 89 90 |
# File 'app/models/stall/models/product_list.rb', line 88 def active? true end |
#checkoutable? ⇒ Boolean
84 85 86 |
# File 'app/models/stall/models/product_list.rb', line 84 def checkoutable? line_items.length > 0 end |
#eot_subtotal ⇒ Object
58 59 60 |
# File 'app/models/stall/models/product_list.rb', line 58 def eot_subtotal line_items.map(&:eot_price).sum end |
#reset_state! ⇒ Object
44 45 46 |
# File 'app/models/stall/models/product_list.rb', line 44 def reset_state! update_column(:state, wizard.steps.first) 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
52 53 54 55 56 |
# File 'app/models/stall/models/product_list.rb', line 52 def subtotal price = line_items.map(&:price).sum price = Money.new(price, currency) unless Money === price price end |
#to_param ⇒ Object
48 49 50 |
# File 'app/models/stall/models/product_list.rb', line 48 def to_param persisted? ? token : 'empty-cart' end |
#total_eot_price ⇒ Object
68 69 70 |
# File 'app/models/stall/models/product_list.rb', line 68 def total_eot_price items.map(&:eot_price).sum end |
#total_price ⇒ Object
62 63 64 65 66 |
# File 'app/models/stall/models/product_list.rb', line 62 def total_price price = items.map(&:price).sum price = Money.new(price, currency) unless Money === price price end |
#total_quantity ⇒ Object
76 77 78 |
# File 'app/models/stall/models/product_list.rb', line 76 def total_quantity line_items.map(&:quantity).sum end |
#total_vat ⇒ Object
72 73 74 |
# File 'app/models/stall/models/product_list.rb', line 72 def total_vat items.map(&:vat).sum end |
#wizard ⇒ Object
80 81 82 |
# File 'app/models/stall/models/product_list.rb', line 80 def wizard @wizard ||= self.class.wizard end |