Class: SolidusSubscriptions::OrderBuilder

Inherits:
Object
  • Object
show all
Defined in:
app/models/solidus_subscriptions/order_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(order) ⇒ SolidusSubscriptions::OrderBuilder

Get a new instance of a OrderBuilder

Parameters:

  • order (Spree::Order)

    The order to be built



12
13
14
# File 'app/models/solidus_subscriptions/order_builder.rb', line 12

def initialize(order)
  @order = order
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



5
6
7
# File 'app/models/solidus_subscriptions/order_builder.rb', line 5

def order
  @order
end

Instance Method Details

#add_line_items(items) ⇒ Array<Spree::LineItem] The collection that was passed in

Add line items for to an order. If the order already has a line item for a given variant_id, update the quantity. Otherwise add the line item to the order.

Parameters:

  • items (Array<Spree::LineItem>)

    The order to add the line item to

Returns:

  • (Array<Spree::LineItem] The collection that was passed in)

    Array<Spree::LineItem] The collection that was passed in



22
23
24
# File 'app/models/solidus_subscriptions/order_builder.rb', line 22

def add_line_items(items)
  items.map { |item| add_item_to_order(item) }
end