Class: Redshop::AddToCart
- Inherits:
-
Object
- Object
- Redshop::AddToCart
- Defined in:
- app/services/redshop/add_to_cart.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(cart, product) ⇒ AddToCart
constructor
A new instance of AddToCart.
Constructor Details
#initialize(cart, product) ⇒ AddToCart
Returns a new instance of AddToCart.
3 4 5 6 |
# File 'app/services/redshop/add_to_cart.rb', line 3 def initialize(cart, product) @cart = cart @product = product end |
Instance Method Details
#call ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/services/redshop/add_to_cart.rb', line 8 def call if product_added? # increment quantity of this product in the cart $redis.hincrby(@cart, @product, 1) else # create cart(hash) and put the one product $redis.hset(@cart, @product, 1) end increment_cart_count end |