Class: ShoppingCart::AddCheckoutAddresses

Inherits:
Rectify::Command
  • Object
show all
Defined in:
app/commands/shopping_cart/add_checkout_addresses.rb

Instance Method Summary collapse

Constructor Details

#initialize(order, params) ⇒ AddCheckoutAddresses

Returns a new instance of AddCheckoutAddresses.



3
4
5
6
# File 'app/commands/shopping_cart/add_checkout_addresses.rb', line 3

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

Instance Method Details

#callObject



8
9
10
11
12
13
14
# File 'app/commands/shopping_cart/add_checkout_addresses.rb', line 8

def call
  @billing = address :billing
  @billing.valid? ? save_billing : write_errors(:billing, @billing)

  @shipping = use_billing? ? address(:billing) : address(:shipping)
  @shipping.valid? ? save_shipping : write_errors(:shipping, @shipping)
end