Class: Stall::AddToProductListService
- Inherits:
-
BaseService
- Object
- BaseService
- Stall::AddToProductListService
- Defined in:
- app/services/stall/add_to_product_list_service.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#product_list ⇒ Object
readonly
Returns the value of attribute product_list.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(product_list, params) ⇒ AddToProductListService
constructor
A new instance of AddToProductListService.
- #line_item ⇒ Object
- #line_item_params? ⇒ Boolean
Constructor Details
#initialize(product_list, params) ⇒ AddToProductListService
Returns a new instance of AddToProductListService.
5 6 7 8 |
# File 'app/services/stall/add_to_product_list_service.rb', line 5 def initialize(product_list, params) @product_list = product_list @params = params end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'app/services/stall/add_to_product_list_service.rb', line 3 def params @params end |
#product_list ⇒ Object (readonly)
Returns the value of attribute product_list.
3 4 5 |
# File 'app/services/stall/add_to_product_list_service.rb', line 3 def product_list @product_list end |
Instance Method Details
#call ⇒ Object
10 11 12 13 |
# File 'app/services/stall/add_to_product_list_service.rb', line 10 def call fail NotImplementedError, 'Override #call in Stall::AddToProductListService subclasses' end |
#line_item ⇒ Object
15 16 17 18 19 |
# File 'app/services/stall/add_to_product_list_service.rb', line 15 def line_item @line_item ||= sellable.to_line_item.tap do |line_item| line_item.quantity = quantity end end |
#line_item_params? ⇒ Boolean
21 22 23 |
# File 'app/services/stall/add_to_product_list_service.rb', line 21 def line_item_params? line_item_params.any? end |