summaryrefslogtreecommitdiff
path: root/app/services/addresses/destroy_address_service.rb
blob: e217d112e3ae38df794933f8901436246d0493a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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