Forum: Ruby get methods from module

97334b75c93574ed3e514f33849f0953?d=identicon&s=25 Mario Ruiz (tcblues)
on 2016-09-28 14:30
I have something like this
module MyModule1
  module MyModule2
    def self.method1
    def self.method2

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:

nothing is captured but if i remove the self. yes I get the methods but
I need to use the self.
0fa73332c8e4a3b06ea439fd3f034322?d=identicon&s=25 Ronald Fischer (rovf)
on 2016-09-29 11:28
You didn't define any instance methods. You will find your two methods
if you do a

97334b75c93574ed3e514f33849f0953?d=identicon&s=25 Mario Ruiz (tcblues)
on 2016-10-12 11:40
by doing that i get all methods not only the ones I created
Cc704ce316e72af824ccd38cfa53104b?d=identicon&s=25 Raja Gopalan (arc)
on 2016-10-14 12:52
puts MyModule1::MyModule2::methods(false)

97334b75c93574ed3e514f33849f0953?d=identicon&s=25 Mario Ruiz (tcblues)
on 2016-10-18 13:52
Thanks a lot!!!!
0fa73332c8e4a3b06ea439fd3f034322?d=identicon&s=25 Ronald Fischer (rovf)
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).
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.