From fa016aa761fbf20d9fab0fbea67dc8fc5f82a98d Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Fri, 26 Jun 2020 14:45:44 +0300 Subject: [PATCH] convert if to return unless --- app/models/actions/contact_update.rb | 48 ++++++++++++++-------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/app/models/actions/contact_update.rb b/app/models/actions/contact_update.rb index 6b237ca65..5b94cf918 100644 --- a/app/models/actions/contact_update.rb +++ b/app/models/actions/contact_update.rb @@ -53,33 +53,33 @@ module Actions end def maybe_update_ident - if ident[:ident] - if contact.identifier.valid? - submitted_ident = ::Contact::Ident.new(code: ident[:ident], - type: ident[:ident_type], - country_code: ident[:ident_country_code]) + return unless ident[:ident] - if submitted_ident != contact.identifier - contact.add_epp_error('2308', nil, nil, I18n.t('epp.contacts.errors.valid_ident')) - @error = true - end - else - ident_update_attempt = ident[:ident] != contact.ident + if contact.identifier.valid? + submitted_ident = ::Contact::Ident.new(code: ident[:ident], + type: ident[:ident_type], + country_code: ident[:ident_country_code]) - if ident_update_attempt - contact.add_epp_error('2308', nil, nil, I18n.t('epp.contacts.errors.ident_update')) - @error = true - end - - identifier = ::Contact::Ident.new(code: ident[:ident], - type: ident[:ident_type], - country_code: ident[:ident_country_code]) - - identifier.validate - - contact.identifier = identifier - contact.ident_updated_at ||= Time.zone.now + if submitted_ident != contact.identifier + contact.add_epp_error('2308', nil, nil, I18n.t('epp.contacts.errors.valid_ident')) + @error = true end + else + ident_update_attempt = ident[:ident] != contact.ident + + if ident_update_attempt + contact.add_epp_error('2308', nil, nil, I18n.t('epp.contacts.errors.ident_update')) + @error = true + end + + identifier = ::Contact::Ident.new(code: ident[:ident], + type: ident[:ident_type], + country_code: ident[:ident_country_code]) + + identifier.validate + + contact.identifier = identifier + contact.ident_updated_at ||= Time.zone.now end end