From 14d407879c9fa08b8bf063cfbfa3160c4b464a2b Mon Sep 17 00:00:00 2001 From: Kristina Lim Date: Sat, 30 Mar 2019 00:41:23 +0800 Subject: [PATCH] Rename method OrderSyncer#update_ship_address_for This method has become only a small part of the logic for updating the order's ship address. This no longer follows the method naming convention within OrderSyncer where update_*_for describes almost the complete logic for updating the association. This is renamed in preparation for extraction of the complete update logic for ship_address. The new method will be named update_ship_address_for. --- app/services/order_syncer.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/services/order_syncer.rb b/app/services/order_syncer.rb index 0d04716fd6..ca1ab01da7 100644 --- a/app/services/order_syncer.rb +++ b/app/services/order_syncer.rb @@ -38,7 +38,7 @@ class OrderSyncer # are ignored or not. pickup_to_delivery = force_ship_address_required?(order) if !pickup_to_delivery || order.shipment.present? - update_ship_address_for(order) if (ship_address.changes.keys & relevant_address_attrs).any? + save_ship_address_in_order(order) if (ship_address.changes.keys & relevant_address_attrs).any? end if !pickup_to_delivery || order.shipment.blank? order.updater.__send__(:shipping_address_from_distributor) @@ -59,11 +59,6 @@ class OrderSyncer order.bill_address.update_attributes(bill_address.attributes.slice(*relevant_address_attrs)) end - def update_ship_address_for(order) - return unless ship_address_updatable?(order) - order.ship_address.update_attributes(ship_address.attributes.slice(*relevant_address_attrs)) - end - def update_payment_for(order) payment = order.payments.with_state('checkout').where(payment_method_id: payment_method_id_was).last if payment @@ -116,6 +111,11 @@ class OrderSyncer end end + def save_ship_address_in_order(order) + return unless ship_address_updatable?(order) + order.ship_address.update_attributes(ship_address.attributes.slice(*relevant_address_attrs)) + end + def pending_shipment_with?(order, shipping_method_id) return false unless order.shipment.present? && order.shipment.state == "pending" order.shipping_method.id == shipping_method_id