I'm trying to figure out how to dynamically create methods
class MyClass
def initialize(dynamic_methods)
@arr = Array.new(dynamic_methods)
@arr.each { |m|
self.class.class_eval do
def m(*value)
puts value
end
end
}
end
end
tmp = MyClass.new ['method1', 'method2', 'method3']
Unfortunately this only creates the method m but I need to create methods based on the value of m, ideas?