Class: Spree::OrderUpdateAttributes

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/order_update_attributes.rb

Instance Method Summary collapse

Constructor Details

#initialize(order, attributes, request_env: nil) ⇒ OrderUpdateAttributes

Returns a new instance of OrderUpdateAttributes

Parameters:

  • order (Order)

    existing (persisted) order

  • attributes (Hash)

    attributes which are assigned to the new order. These attributes should already have been filtered.

    • :payments_attributes attributes



7
8
9
10
11
12
# File 'app/models/spree/order_update_attributes.rb', line 7

def initialize(order, attributes, request_env: nil)
  @order = order
  @attributes = attributes.dup
  @payments_attributes = @attributes.delete(:payments_attributes) || []
  @request_env = request_env
end

Instance Method Details

#applyObject

Assign the attributes to the order and save the order

Returns:

  • true if saved, otherwise false and errors will be set on the order



16
17
18
19
20
21
# File 'app/models/spree/order_update_attributes.rb', line 16

def apply
  assign_order_attributes
  assign_payments_attributes

  order.save
end