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



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

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

#callObject Also known as: apply

Assign the attributes to the order and save the order

Returns:

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



18
19
20
21
22
23
24
25
# File 'app/models/spree/order_update_attributes.rb', line 18

def call
  order.validate_payments_attributes(@payments_attributes)

  assign_order_attributes
  assign_payments_attributes

  order.save
end