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 00ee934..c02254a 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