summaryrefslogtreecommitdiff
path: root/app/controllers/services/create_address_service.rb
blob: 431ccd13875d8ea281796572438f0a92fbbdc556 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

module Services
  # The service for address creation.
  class CreateAddressService < AddressServicesBase
    attr_reader :address

    def call
      if already_existing_address.nil?
        @address = Address.new(@params)
        @address.user_accounts << @user_account
        @address.save
      else
        add_address_to_user_addresses
        @address = already_existing_address
      end
    end
  end
end