I am trying to create a method that can be called by any class, similar to how .is_a? can be called by any class. How can one go about this?
I have tried using alias_method and Class.send(method) to achieve my result, but neither worked.
I am trying to create a method that can be called by any class, similar to how .is_a? can be called by any class. How can one go about this?
I have tried using alias_method and Class.send(method) to achieve my result, but neither worked.
Open the Object class and write your method there.
class Object
def your_method
end
end
Now any class object can access this method.