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

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'app/models/stall/models/product_list.rb', line 78

def active?
  true
end

#checkoutable?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'app/models/stall/models/product_list.rb', line 74

def checkoutable?
  line_items.length > 0
end

#eot_subtotalObject



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

#stateObject



45
46
47
# File 'app/models/stall/models/product_list.rb', line 45

def state
  read_attribute(:state).try(:to_sym)
end

#subtotalObject



58
59
60
# File 'app/models/stall/models/product_list.rb', line 58

def subtotal
  ensure_money(line_items.map(&:price).sum)
end

#to_paramObject



54
55
56
# File 'app/models/stall/models/product_list.rb', line 54

def to_param
  persisted? ? token : 'empty-cart'
end

#total_quantityObject



66
67
68
# File 'app/models/stall/models/product_list.rb', line 66

def total_quantity
  line_items.map(&:quantity).compact.sum
end

#wizardObject



70
71
72
# File 'app/models/stall/models/product_list.rb', line 70

def wizard
  @wizard ||= self.class.wizard
end