I have two classes
class ClassOne
def do_something
[...]
end
end
class ClassTwo
def do_something
[...]
end
end
I am getting a class name (either ClassOne or ClassTwo) from the database and I want to call do_something in that class
so I have
class_name = "ClassOne"
and I want to call ClassOne.do_something or ClassTwo.do_something if class_name is equals to “ClassTwo”.
I can’t do it using a simple if condition, I have many classes and am checking if the class exists before calling..
Is there a way to do it?
For vanilla ruby:
For Rails: