mirror of
https://github.com/discourse/discourse.git
synced 2025-06-14 19:29:21 +08:00
DEV: Stop polluting all Ruby classes
The `ReviewableScore` model was defining class methods on `self.class` from a singleton context so instead of defining methods on `ReviewableScore` it was defining them on `Class`, so basically on every existing class. This patch resolves this issue. Using `enum` from `ActiveRecord` in the future will avoid this kind of problems.
This commit is contained in:

committed by
Loïc Guitaut

parent
3c5b1faab4
commit
74387e83b6
@ -49,7 +49,7 @@ class ReviewableScore < ActiveRecord::Base
|
|||||||
# Generate `pending?`, `rejected?`, etc helper methods
|
# Generate `pending?`, `rejected?`, etc helper methods
|
||||||
statuses.each do |name, id|
|
statuses.each do |name, id|
|
||||||
define_method("#{name}?") { status == id }
|
define_method("#{name}?") { status == id }
|
||||||
self.class.define_method(name) { where(status: id) }
|
singleton_class.define_method(name) { where(status: id) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def score_type
|
def score_type
|
||||||
|
Reference in New Issue
Block a user