diff options
author | Gareth Rees <gareth@mysociety.org> | 2015-01-23 13:33:32 +0000 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2015-01-23 17:07:03 +0000 |
commit | 39749fc93e63c7b28fa964f54c989b8e5decf1e3 (patch) | |
tree | 774aaa136a309a17339d900433a15d25042de134 | |
parent | 43e031e3d91c12542672fdbb1ce2985f666114ff (diff) |
Remove home-grown Array#to_sentence dup
- to_sentence does the same job as the removed code.
- Clean up the conditional with .any? and implicit returns
-rw-r--r-- | app/models/public_body.rb | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb index a9cdfeab2..e66c85b4f 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -354,15 +354,11 @@ class PublicBody < ActiveRecord::Base types.push(desc) end end - if types.size > 0 - ret = types[0, types.size - 1].join(", ") - if types.size > 1 - ret = ret + " and " - end - ret = ret + types[-1] - return ret.html_safe + + if types.any? + types.to_sentence(:last_word_connector => ' and ').html_safe else - return _("A public authority") + _("A public authority") end end |