Replace if..else with hash lookup (#578)
This commit is contained in:
parent
1b68c284b0
commit
35eddd5131
1 changed files with 6 additions and 7 deletions
|
|
@ -104,14 +104,13 @@ class Reaction < ApplicationRecord
|
|||
reactable.index! if reactable_type == "Article"
|
||||
end
|
||||
|
||||
BASE_POINTS = {
|
||||
"vomit" => -50.0,
|
||||
"thumbsdown" => -10.0
|
||||
}.freeze
|
||||
|
||||
def assign_points
|
||||
base_points = if category == "vomit"
|
||||
-50.0
|
||||
elsif category == "thumbsdown"
|
||||
-10.0
|
||||
else
|
||||
1.0
|
||||
end
|
||||
base_points = BASE_POINTS.fetch(category, 1.0)
|
||||
self.points = user ? (base_points * user.reputation_modifier) : -5
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue