Module: Comable::CartOwner

Included in:
Customer
Defined in:
lib/comable/cart_owner.rb

Defined Under Namespace

Classes: Cart

Instance Method Summary collapse

Instance Method Details

#add_cart_item(obj, quantity: 1) ⇒ Object



3
4
5
6
7
# File 'lib/comable/cart_owner.rb', line 3

def add_cart_item(obj, quantity: 1)
  process_cart_item(obj) do |stock|
    add_stock_to_cart(stock, quantity)
  end
end

#cartObject



23
24
25
# File 'lib/comable/cart_owner.rb', line 23

def cart
  Cart.new(cart_items)
end

#cart_itemsObject



19
20
21
# File 'lib/comable/cart_owner.rb', line 19

def cart_items
  fail 'You should implement cart_items method.'
end

#remove_cart_item(obj, quantity: -1)) ⇒ Object



9
10
11
# File 'lib/comable/cart_owner.rb', line 9

def remove_cart_item(obj, quantity: -1)
  add_cart_item(obj, quantity: quantity)
end

#reset_cart_item(obj, quantity: 0) ⇒ Object



13
14
15
16
17
# File 'lib/comable/cart_owner.rb', line 13

def reset_cart_item(obj, quantity: 0)
  process_cart_item(obj) do |stock|
    reset_stock_from_cart(stock, quantity)
  end
end