diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/public_body.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 91ee9fd77..ac924a941 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -290,6 +290,9 @@ class PublicBody < ActiveRecord::Base # Guess home page from the request email, or use explicit override, or nil # if not known. + # + # TODO: PublicBody#calculated_home_page would be a good candidate to cache + # in an instance variable def calculated_home_page if home_page && !home_page.empty? home_page[URI::regexp(%w(http https))] ? home_page : "http://#{home_page}" @@ -525,6 +528,8 @@ class PublicBody < ActiveRecord::Base # Return the domain part of an email address, canonicalised and with common # extra UK Government server name parts removed. + # + # TODO: Extract to library class def self.extract_domain_from_email(email) email =~ /@(.*)/ if $1.nil? @@ -542,6 +547,7 @@ class PublicBody < ActiveRecord::Base return ret end + # TODO: Could this be defined as `sorted_versions.reverse`? def reverse_sorted_versions versions.sort { |a,b| b.version <=> a.version } end @@ -554,13 +560,16 @@ class PublicBody < ActiveRecord::Base !notes.nil? && notes != "" end + # TODO: Deprecate this method. Its only used in a couple of views so easy to + # update to just call PublicBody#notes def notes_as_html notes end def notes_without_html - # assume notes are reasonably behaved HTML, so just use simple regexp on this - @notes_without_html ||= (self.notes.nil? ? '' : self.notes.gsub(/<\/?[^>]*>/, "")) + # assume notes are reasonably behaved HTML, so just use simple regexp + # on this + @notes_without_html ||= (notes.nil? ? '' : notes.gsub(/<\/?[^>]*>/, "")) end def json_for_api |