I am creating a code that is supposed to run in different environments (with a small difference in code each). The same class might define a method in one but not in the other. That way, I can use something like:
rescue NoMethodError
to catch the event when the method is not defined in one particular class, but catching exceptions is not a right logic flux.
Does it exist an alternative, something like present to know if the method is defined in a particular class? This class is a service, not an ActionController
I was thinking in something like:
class User
def name
"my name"
end
end
And then
User.new.has_method?(name)
Or something similar.