module TheCart::Item::InstanceMethods

Public Instance Methods

update_cart_details() click to toggle source
# File lib/the_cart/item.rb, line 48
def update_cart_details
  TheCart.redis.multi do
    attr_hash = {}

    self.class.cart_fields.each do |field|
      attr_hash[field] = self.send(field)
    end

    attr_hash["price"] = self.send(self.class.price_column)
    attr_hash["class"] = self.class.name
    
    TheCart.redis.hmset cart_item_id_key, *attr_hash.to_a
  end
  true
end

Protected Instance Methods

cart_item_id_key() click to toggle source
# File lib/the_cart/item.rb, line 67
def cart_item_id_key
  "the_cart:#{self.id}:item_details"
end