Refactor set_default_assigned_role to be more easily read.
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 14 Mar 2018 09:35:58 +0000 (17:35 +0800)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 14 Mar 2018 09:35:58 +0000 (17:35 +0800)
app/models/issue.rb

index 00ee934f7a0fe430d1b54720fb85837e948206ab..c02254a1b4b1cf3743bc5a1e7503fc124dea3de6 100644 (file)
@@ -95,7 +95,11 @@ class Issue < ActiveRecord::Base
   end
 
   def set_default_assigned_role
-    role = %w[Note].include?(reportable.class.name) ? "moderator" : "administrator"
-    self.assigned_role = role if assigned_role.blank?
+    if assigned_role.blank?
+      self.assigned_role = case reportable
+                           when Note then "moderator"
+                           else "administrator"
+                           end
+    end
   end
 end