0

I started to touch the meta-programming in Ruby

If I want to trace all the details in meta-programming

Like to lookup m_tbl methods_table in a specific object,

I mean if there is a test method and defined in class B A < B B < C

What's the convenient way to know the method is defined in class B

Any good methods or tools to share about discovery the meta-programing in Ruby.

To look up all the relation between object's hierachy relation in quick way.

enter image description here

Thanks !

newBike
  • 14,385
  • 29
  • 109
  • 192
  • possible duplicate of [How to find where a method is defined at runtime?](http://stackoverflow.com/questions/175655/how-to-find-where-a-method-is-defined-at-runtime) – Uri Agassi May 09 '14 at 05:36

1 Answers1

1

Use method method:

class C
  def c
  end
end

class B < C
  def b
  end
end

class A < B
  def a
  end
end

a = A.new

a.method(:b).owner
# => B
Uri Agassi
  • 36,848
  • 14
  • 76
  • 93