I’m trying to check if a method is defined in a module using Module.method_defined?(:method) and it is returning false it should be returing true.
module Something
def self.another
1
end
end
Something.methods has ‘another’ listed but Something.method_defined?(:another) returns false.
Is this maybe not working because the method is defined on self? If this is the case is there another way to check if the method is defined on the module other than using method_defined??
To know whether the module has a module method, you can use respond_to?
on the
module:
method_defined? will tell you whether INSTANCES of the class with the module included responds to the given method.