DEV: Don't polute all ActiveRecord classes (#15103)

DEV: Don’t polute all ActiveRecord classes (#15103)

pending, approved, rejected, ignored, and deleted scope method were accessible on all model classes… :joy:

Fixes Creating scope :pending. Overwriting existing method DiscoursePostEvent::EventDate.pending. warnings.

diff --git a/app/models/reviewable.rb b/app/models/reviewable.rb
index 08d0264..27baea2 100644
--- a/app/models/reviewable.rb
+++ b/app/models/reviewable.rb
@@ -80,7 +80,7 @@ class Reviewable < ActiveRecord::Base
   # Generate `pending?`, `rejected?`, etc helper methods
   statuses.each do |name, id|
     define_method("#{name}?") { status == id }
-    self.class.define_method(name) { where(status: id) }
+    singleton_class.define_method(name) { where(status: id) }
   end
 
   def self.default_visible

GitHub sha: 1441226b1a0c95ad4ffbf784f5b55dc207447349

This commit appears in #15103 which was approved by tgxworld. It was merged by tgxworld.