Class: Stall::AddToProductListService

Inherits:
BaseService show all
Defined in:
app/services/stall/add_to_product_list_service.rb

Direct Known Subclasses

AddToCartService, AddToWishListService

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#paramsObject (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_listObject (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

#callObject



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_itemObject



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

Returns:

  • (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