On Mon, Oct 15, 2012 at 7:13 AM, 前川 享仁 <[email protected]> wrote:
> What I intended to do was to collect the method names of each > class/module into the vareable named @ancestor_classes and > included_modules, respectively. That's not a good idea IMHO since the data is redundant and you need this for debugging / investigative purposes only anyway. > As the result, however, I couldn't find any methods named 'render'.What > is wrong in the above code? I'm really confused about this because I > thought it was the best way to use Module#public_instance_methods, > Module#protected_instance_methods and Module#private_instance_methods to > find the definitions of methods in superclasses and included modules. > > In general, what is the right way to find the methods by tracing modules > and superclasses?I would very much appreciate any helps and advice. Just access the method and output it with p: $ ruby -e 'class X < Array; end;o = X.new; p o.method(:size)' #<Method: X(Array)#length> You'll see the defining class in brackets. You can also access it explicitly: $ ruby -e 'class X < Array; end;o = X.new; p o.method(:size).owner' Array Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/ruby-talk-google?hl=en
