Class: Stall::ProductList
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Stall::ProductList
- Defined in:
- app/models/stall/product_list.rb
Direct Known Subclasses
Instance Method Summary collapse
- #reset_state! ⇒ Object
- #state ⇒ Object
- #to_param ⇒ Object
- #total_eot_price ⇒ Object
- #total_price ⇒ Object
- #total_quantity ⇒ Object
- #total_vat ⇒ Object
- #wizard ⇒ Object
Instance Method Details
#reset_state! ⇒ Object
20 21 22 |
# File 'app/models/stall/product_list.rb', line 20 def reset_state! update_column(:state, wizard.steps.first) end |
#state ⇒ Object
16 17 18 |
# File 'app/models/stall/product_list.rb', line 16 def state read_attribute(:state).try(:to_sym) end |
#to_param ⇒ Object
24 25 26 |
# File 'app/models/stall/product_list.rb', line 24 def to_param token end |
#total_eot_price ⇒ Object
32 33 34 |
# File 'app/models/stall/product_list.rb', line 32 def total_eot_price line_items.map(&:eot_price).sum end |
#total_price ⇒ Object
28 29 30 |
# File 'app/models/stall/product_list.rb', line 28 def total_price line_items.map(&:price).sum end |
#total_quantity ⇒ Object
40 41 42 |
# File 'app/models/stall/product_list.rb', line 40 def total_quantity line_items.map(&:quantity).sum end |
#total_vat ⇒ Object
36 37 38 |
# File 'app/models/stall/product_list.rb', line 36 def total_vat line_items.map(&:vat).sum end |
#wizard ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/stall/product_list.rb', line 44 def wizard @wizard ||= begin wizard_name = Stall.config.default_checkout_wizard if (wizard = Stall::Utils.try_load_constant(wizard_name)) wizard else raise Stall::Checkout::WizardNotFoundError.new, "The checkout wizard #{ wizard_name } was not found. You must generate it " + "with `rails g stall:wizard #{ wizard_name.underscore.gsub('_checkout_wizard', '') }`" end end end |