From 7265af094ed16c36632128bccdcf84a3796c2359 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Sat, 25 Mar 2023 00:10:33 -0600 Subject: AƱade specs de addresscontroller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/addresses/create_address_service.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 app/controllers/services/addresses/create_address_service.rb (limited to 'app/controllers/services/addresses/create_address_service.rb') diff --git a/app/controllers/services/addresses/create_address_service.rb b/app/controllers/services/addresses/create_address_service.rb new file mode 100644 index 0000000..b634a2b --- /dev/null +++ b/app/controllers/services/addresses/create_address_service.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Services + 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 +end -- cgit v1.2.3