Class: Workarea::WishListSession
- Inherits:
-
Object
- Object
- Workarea::WishListSession
- Defined in:
- app/services/workarea/wish_list_session.rb
Overview
WishListSession is responsible for storing a representation of a product that will later be added to a user’s Wish List.
Instance Attribute Summary collapse
-
#cookies ⇒ Object
readonly
Returns the value of attribute cookies.
Instance Method Summary collapse
-
#add_item(wish_list) ⇒ void
Add the current item in the cookies to a the given wish list.
-
#initialize(cookies) ⇒ WishListSession
constructor
A new instance of WishListSession.
-
#store_item(params) ⇒ void
Store a form-posted representation of a Wish List Item.
Constructor Details
#initialize(cookies) ⇒ WishListSession
Returns a new instance of WishListSession.
8 9 10 |
# File 'app/services/workarea/wish_list_session.rb', line 8 def initialize() @cookies = end |
Instance Attribute Details
#cookies ⇒ Object (readonly)
Returns the value of attribute cookies.
5 6 7 |
# File 'app/services/workarea/wish_list_session.rb', line 5 def @cookies end |
Instance Method Details
#add_item(wish_list) ⇒ void
This method returns an undefined value.
Add the current item in the cookies to a the given wish list.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/services/workarea/wish_list_session.rb', line 28 def add_item(wish_list) product_id = ['wish_list_product_id'] sku = ['wish_list_sku'] quantity = ['wish_list_quantity'] customizations = ['wish_list_customizations'] wish_list.add_item( product_id, sku, quantity.to_i, OrderItemDetails.find!(sku).to_h, customizations || {} ) collection_keys.each do |key| .delete("wish_list_#{key}") end end |
#store_item(params) ⇒ void
This method returns an undefined value.
Store a form-posted representation of a Wish List Item. This would include the product_id, sku and quantity of that item.
17 18 19 20 21 |
# File 'app/services/workarea/wish_list_session.rb', line 17 def store_item(params) collection_keys.each do |key| ["wish_list_#{key}"] = params[key] if params[key].present? end end |