Sha256: 21abb88e22b84f01bf6de69930e529b56d764ed302d7acbcae26bdc69fa472d1
Contents?: true
Size: 846 Bytes
Versions: 17
Compression:
Stored size: 846 Bytes
Contents
module Spree module Addresses class Update prepend Spree::ServiceModule::Base include Spree::Addresses::Helper attr_accessor :country def call(address:, address_params:) address_params[:country_id] ||= address.country_id address_params = fill_country_and_state_ids(address_params) if address&.editable? address.update(address_params) ? success(address) : failure(address) else if new_address(address_params).valid? address.destroy success(new_address) else failure(new_address) end end end private def new_address(address_params = {}) @new_address ||= ::Spree::Address.find_or_create_by(address_params.except(:id, :updated_at, :created_at)) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems