From 753bf8499ba5d8815db8d08a1dcf69caa20660cf Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Sat, 1 Apr 2023 12:00:33 -0600 Subject: Mejora estructura del proyecto --- app/services/addresses/destroy_address_service.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 app/services/addresses/destroy_address_service.rb (limited to 'app/services/addresses/destroy_address_service.rb') diff --git a/app/services/addresses/destroy_address_service.rb b/app/services/addresses/destroy_address_service.rb new file mode 100644 index 0000000..e217d11 --- /dev/null +++ b/app/services/addresses/destroy_address_service.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Addresses + # The service for address deletion. + class DestroyAddressService < AddressServicesBase + def initialize(user_account, params, address) + super(user_account, params) + @address = address + end + + def call + UserAccountAddress.find_by(address_id: @address.id, user_account_id: @user_account.id).destroy + return unless @address.user_accounts.count.zero? + + @address.destroy + end + end +end -- cgit v1.2.3