如果您尝试以元编程方式创建类方法,这将非常有用:
def self.create_methods(method_name)
# To create instance methods:
define_method method_name do
...
end
# To create class methods that refer to the args on create_methods:
???
end
Run Code Online (Sandbox Code Playgroud)
我的回答是......