aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenare Degan <henare.degan@gmail.com>2012-02-16 17:18:10 +1100
committerSeb Bacon <seb.bacon@gmail.com>2012-03-13 13:55:46 +0000
commitfc1671a25804964fee14c4e02a4746cadb3aac12 (patch)
tree57bdded427c64140aca0c7186f08cb07c78da454
parent53b128aafadd0c134feac82aa0de36378c752bf7 (diff)
Refactor method
-rw-r--r--app/models/public_body.rb21
1 files changed, 4 insertions, 17 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 23f71333d..f8c12e1e8 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -282,24 +282,11 @@ class PublicBody < ActiveRecord::Base
# Guess home page from the request email, or use explicit override, or nil
# if not known.
def calculated_home_page
- # manual override for ones we calculate wrongly
- if self.home_page != ''
- # Add standard URL prefix
- if home_page[0..10] == 'http://www.'
- return self.home_page
- else
- return "http://www.#{self.home_page}"
- end
+ if home_page && !home_page.empty?
+ home_page[0..10] == 'http://www.' ? home_page : "http://www.#{home_page}"
+ elsif request_email_domain
+ "http://www.#{request_email_domain}"
end
-
- # extract the domain name from the FOI request email
- url = self.request_email_domain
- if url.nil?
- return nil
- end
-
- # add standard URL prefix
- return "http://www." + url
end
# Are all requests to this body under the Environmental Information Regulations?