Class: ShoppingCart::CreateOrderItem

Inherits:
Rectify::Command
  • Object
show all
Defined in:
app/services/shopping_cart/create_order_item.rb

Instance Method Summary collapse

Constructor Details

#initialize(params:, order:) ⇒ CreateOrderItem

Returns a new instance of CreateOrderItem.



3
4
5
6
# File 'app/services/shopping_cart/create_order_item.rb', line 3

def initialize(params:, order:)
  @params = params
  @order = order
end

Instance Method Details

#callObject



8
9
10
11
12
# File 'app/services/shopping_cart/create_order_item.rb', line 8

def call
  create_order unless @order
  find_order_item ? update_order_item_quantity : create_new_order_item
  broadcast(:ok)
end