From c7f95c41a2f87746f52dde097a36147eab1746c0 Mon Sep 17 00:00:00 2001 From: Maciej Szlosarczyk Date: Thu, 28 May 2020 14:24:18 +0300 Subject: [PATCH] Split "big" method into two smaller ones --- app/models/retained_domains.rb | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/app/models/retained_domains.rb b/app/models/retained_domains.rb index 8ff8358f0..d9ab42b3b 100644 --- a/app/models/retained_domains.rb +++ b/app/models/retained_domains.rb @@ -63,17 +63,8 @@ class RetainedDomains end def domain_to_jsonable(domain) - status = case domain - when ReservedDomain then RESERVED - when BlockedDomain then BLOCKED - when Dispute then DISPUTED - end - - domain_name = case domain - when Dispute then domain.domain_name - else domain.name - end - + status = get_status(domain) + domain_name = get_domain_name(domain) punycode = SimpleIDN.to_ascii(domain_name) { @@ -82,4 +73,19 @@ class RetainedDomains punycode_name: punycode, } end + + def get_status(domain) + case domain + when ReservedDomain then RESERVED + when BlockedDomain then BLOCKED + when Dispute then DISPUTED + end + end + + def get_domain_name(domain) + case domain + when Dispute then domain.domain_name + else domain.name + end + end end