refactor User and TrustLevel a bit

* rename `User#password_required` to `User#password_required!`
* emails with "i" @ something are a special case as well
* get rid of `self.` and returns where possible
* prefer "unless a" instead of "if !a"
* `unread_notifications` without manually iterating
* introduce `User#moderator?`
* introduce `TrustLevel#valid_key?`, `TrustLevel#compare`, and
  `TrustLevel#level_key`
This commit is contained in:
Gosha Arinich
2013-02-28 16:08:56 +03:00
parent 46a02ae5b1
commit d2f3c829db
6 changed files with 109 additions and 117 deletions

View File

@ -13,7 +13,7 @@ class Promotion
# nil users are never promoted
return false if @user.blank?
trust_key = TrustLevel.Levels.invert[@user.trust_level]
trust_key = TrustLevel.level_key(@user.trust_level)
review_method = :"review_#{trust_key.to_s}"
return send(review_method) if respond_to?(review_method)