Below the sample modules (n numbers) which I am using in my project with the same method name(s) with different return value (prefix with module name).
module Example1
def self.ex_method
'example1_with_'
end
end
module Example2
def self.ex_method
'example2_with_'
end
end
I tried to accomplish this using metaprogramming way like #define_method. But, it's not working for me. Is there any way to do it?
array.each do |name|
Object.class_eval <<TES
module #{name}
def self.ex_method
"#{name.downcase}_with_"
end
end
TES
end
Error snap: You could see in the last line says that it's not completed.

irbthe command says, still the method is not closed with end. Why ` is not a good definition` ?irb