# Method origin?

**URL:** <https://rubytalk.org/t/method-origin/40986>\
**Category:** ruby-talk\
**Created:** [28 September 2007 00:20 UTC](https://rubytalk.org/t/method-origin/40986 "2007-09-28T00:20:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Wells](https://avatars.discourse-cdn.com/v4/letter/j/35a633/32.png) [@John\_Wells](https://rubytalk.org/u/John_Wells)\
**Post date:** [28 September 2007 00:20 UTC](https://rubytalk.org/t/method-origin/40986/1 "2007-09-28T00:20:01Z")

</div>

Guys,

In a deep inheritance tree, is there an easy way to determine the origin or source (module, class) of a method?

Thanks,  
John

---

<div class="post-metadata">

**Author:** ![Stefan\_Rusterholz](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@Stefan\_Rusterholz](https://rubytalk.org/u/Stefan_Rusterholz)\
**Post date:** [28 September 2007 01:00 UTC](https://rubytalk.org/t/method-origin/40986/2 "2007-09-28T01:00:57Z")

</div>

John Wells wrote:

> Guys,
> 
> In a deep inheritance tree, is there an easy way to determine the origin  
> or source (module, class) of a method?
> 
> Thanks,  
> John

a) Use fri (fast-ri)  
b) Use Method#inspect, example: .method(:find) # =\> #\<Method:  
Array(Enumerable)#find\>

Regards  
Stefan

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/\](http://www.ruby-forum.com/%5C).

---

<div class="post-metadata">

**Author:** ![Gavin\_Kistner3](https://avatars.discourse-cdn.com/v4/letter/g/dfb087/32.png) [@Gavin\_Kistner3](https://rubytalk.org/u/Gavin_Kistner3)\
**Post date:** [28 September 2007 01:25 UTC](https://rubytalk.org/t/method-origin/40986/3 "2007-09-28T01:25:11Z")

</div>

If you'd like something better than this, then vote for the  
Method#owning\_class (or better name) aspect of RCR 15.

[http://rcrchive.net/rcrs/15](http://rcrchive.net/rcrs/15)

Disclaimer: I proposed that particular RCR. 🙂

> **···**
>
> On Sep 27, 6:20 pm, John Wells \<li...@sourceillustrated.com\> wrote:
> 
> > In a deep inheritance tree, is there an easy way to determine the origin or source (module, class) of a method?

---

<div class="post-metadata">

**Author:** ![Paul\_Brannan](https://avatars.discourse-cdn.com/v4/letter/p/76d3ee/32.png) [@Paul\_Brannan](https://rubytalk.org/u/Paul_Brannan)\
**Post date:** [28 September 2007 14:49 UTC](https://rubytalk.org/t/method-origin/40986/4 "2007-09-28T14:49:38Z")

</div>

Nodewrap can do it:

irb(main):001:0\> require 'nodewrap'  
=\> false  
irb(main):002:0\> Hash.instance\_method(:map).origin\_class  
=\> Enumerable

Paul

> **···**
>
> On Fri, Sep 28, 2007 at 09:20:01AM +0900, John Wells wrote:
> 
> > Guys,
> > 
> > In a deep inheritance tree, is there an easy way to determine the  
> > origin or source (module, class) of a method?

---

<div class="post-metadata">

**Author:** ![Phlip1](https://avatars.discourse-cdn.com/v4/letter/p/df788c/32.png) [@Phlip1](https://rubytalk.org/u/Phlip1)\
**Post date:** [28 September 2007 01:10 UTC](https://rubytalk.org/t/method-origin/40986/5 "2007-09-28T01:10:56Z")

</div>

Stefan Rusterholz wrote:

> John Wells wrote:

> > In a deep inheritance tree,

Note: Deep inheritance trees might be a design issue.

> > is there an easy way to determine the origin  
> > or source (module, class) of a method?

> a) Use fri (fast-ri)  
> b) Use Method#inspect, example: .method(:find) # =\> #\<Method:  
> Array(Enumerable)#find\>

b) seems to assume an irb environment that calls .inspect automatically. Try:

&nbsp;&nbsp;puts .method(:find).inspect

New question: Parsing the (Enumerable) out would be tacky, so how do we do what .inspect was doing when it built that string for us?

> **···**
>
> --  
> &nbsp;&nbsp;Phlip
