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

module Services
  # The base class for all addresses' services.
  class AddressServicesBase
    def initialize(user_account, params)
      @user_account = user_account
      @params = params
    end

    private

    def already_existing_address
      @already_existing_address ||= Address.find_by(params)
    end

    def add_address_to_user_addresses
      already_existing_address.user_accounts << @user_account
      already_existing_address.save
    end
  end
end