I have something like this module MyModule1 module MyModule2 def self.method1 end def self.method2 end end end I need to get the methods declared inside MyModule2 and I need the self. to be able to access it like MyModule1::MyModule2.method1 If i try to get them like this: MyModule1::MyModule2.instance_methods nothing is captured but if i remove the self. yes I get the methods but I need to use the self.
on 2016-09-28 14:30
on 2016-09-29 11:28
You didn't define any instance methods. You will find your two methods if you do a MyModule1::MyModule2::methods
on 2016-10-12 11:40
by doing that i get all methods not only the ones I created
on 2016-10-14 12:52
puts MyModule1::MyModule2::methods(false) #method1 #method2
on 2016-10-18 13:52
Thanks a lot!!!!
on 2016-11-07 09:26
Ruby has no way to track "who" wrote the code to define a method : The definition of a method can occur while executing or requiring something from the Ruby stdlib, or some Gem, or some Code you wrote, and this type of authorship is hard (maybe impossible) to track. You can track all new methods added after a certain time in program execution, by recording first a list of all methods, and later - when you want to know the changes -, recalculate the list of methods and output the difference. As a side effect, you also would get the methods which have been removed from an object (a rare, but possible case).