hawm
(Hawm)
16 فبراير 2021، 5:44ص
2
لا، فأنت تُعدّل الكلاس/الطريقة بدلاً من الملف، لذا قد لا يكون اسم الملف مهماً. إذا لم تكن على دراية بهيكلية الإضافة، يمكنك قراءة بعض أكواد المصادر الرسمية للإضافات.
I’ve been running into a bunch of instances recently of needing to override existing ruby methods from plugins, and thought I’d share my best practices here.
Overriding an instance method
class ::TopicQuery
module BabbleDefaultResults
def default_results(options={})
super(options).where('archetype <> ?', Archetype.chat)
end
end
prepend BabbleDefaultResults
end
Here I’m removing chat topics from an instance method which is returning a list of topics.
The module name BabbleD…