Sha256: 64e01a7e2572b25e72a9d3682f26ced915c58ee088506db4c192cb5ecb3ff450
Contents?: true
Size: 649 Bytes
Versions: 1
Compression:
Stored size: 649 Bytes
Contents
module Redshop class AddToCart def initialize(cart, product) @cart = cart @product = product end 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 private def product_added? # if a product already has been added in a cart true if $redis.hexists(@cart, @product) end def increment_cart_count CartCountService.new(@cart).increment end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
redshop-0.0.1 | app/services/redshop/add_to_cart.rb |