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_quantity ⇒ Object
- #wizard ⇒ Object
Instance Method Details
#active? ⇒ Boolean
78 79 80 |
# File 'app/models/stall/models/product_list.rb', line 78 def active? true end |
#checkoutable? ⇒ Boolean
74 75 76 |
# File 'app/models/stall/models/product_list.rb', line 74 def checkoutable? line_items.length > 0 end |
#eot_subtotal ⇒ Object
62 63 64 |
# File 'app/models/stall/models/product_list.rb', line 62 def eot_subtotal ensure_money(line_items.map(&:eot_price).sum) end |
#reset_state! ⇒ Object
49 50 51 52 |
# File 'app/models/stall/models/product_list.rb', line 49 def reset_state! self.state = wizard.steps.first save(validate: false) if persisted? end |
#state ⇒ Object
45 46 47 |
# File 'app/models/stall/models/product_list.rb', line 45 def state read_attribute(:state).try(:to_sym) end |
#subtotal ⇒ Object
58 59 60 |
# File 'app/models/stall/models/product_list.rb', line 58 def subtotal ensure_money(line_items.map(&:price).sum) end |
#to_param ⇒ Object
54 55 56 |
# File 'app/models/stall/models/product_list.rb', line 54 def to_param persisted? ? token : 'empty-cart' end |
#total_quantity ⇒ Object
66 67 68 |
# File 'app/models/stall/models/product_list.rb', line 66 def total_quantity line_items.map(&:quantity).compact.sum end |
#wizard ⇒ Object
70 71 72 |
# File 'app/models/stall/models/product_list.rb', line 70 def wizard @wizard ||= self.class.wizard end |