Sha256: 6eb26a03e5a36cba7aff8a2ae324a06e88cdb519579f798050691907a1d80668

Contents?: true

Size: 397 Bytes

Versions: 62

Compression:

Stored size: 397 Bytes

Contents

module Workarea
  class AddMultipleCartItems
    def initialize(order, items_params = [])
      @order = order
      @items_params = items_params
    end

    def perform
      items.all?(&:save)
    end

    def perform!
      return false unless items.all?(&:valid?)
      perform
    end

    def items
      @items ||= @items_params.map { |params| Item.new(@order, params) }
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.4.13 app/services/workarea/add_multiple_cart_items.rb
workarea-core-3.4.12 app/services/workarea/add_multiple_cart_items.rb