summaryrefslogtreecommitdiff
path: root/app/controllers/services/address_services_base.rb
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-03-22 20:24:20 -0600
committerHombreLaser <sebastian-440@live.com>2023-03-22 20:24:20 -0600
commite04c9e0fe1b9df2e8e40b87c8a272874192a8d07 (patch)
treeb724bf79034c4f4f9e3ba4ab656b417bc48be575 /app/controllers/services/address_services_base.rb
parent25fd0c4da93d664747eb5e6eca25413cead97452 (diff)
Añade AddressesController
Diffstat (limited to 'app/controllers/services/address_services_base.rb')
-rw-r--r--app/controllers/services/address_services_base.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/controllers/services/address_services_base.rb b/app/controllers/services/address_services_base.rb
new file mode 100644
index 0000000..622873e
--- /dev/null
+++ b/app/controllers/services/address_services_base.rb
@@ -0,0 +1,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