How to dynamically define a class method which will refer to a local variable outside?
Class methods don’t really exist in Ruby, they are just singleton methods of the class object. Singleton methods don’t really exist, either, they are just ordinary instance methods of the object’s singleton class. Since you already know how to define instance methods (using Module#define_method), you already know everything you need to know. You just need … Read more