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

module Services
  module Addresses
    # 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
end