mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 13:03:39 +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:
parent
3c5b1faab4
commit
74387e83b6
|
@ -49,7 +49,7 @@ class ReviewableScore < 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 score_type
|
||||
|
|
Loading…
Reference in New Issue
Block a user