summaryrefslogtreecommitdiff
path: root/app/services/addresses/create_address_service.rb
blob: ef593a445e30c02510256479b8f46de2ec86c060 (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 Addresses
  # 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