我正在开发一个具有一些复杂类/mixin 层次结构的系统。由于有许多层分散在许多不同的文件中,我想快速查看给定方法的超级调用链是什么。
例如
module AAA
def to_s
"AAA " + super()
end
end
module BBB
def to_s
"BBB " + super()
end
end
class MyArray < Array
include AAA
include BBB
def to_s
"MyArray " + super()
end
end
> MyArray.new.to_s
=> "MyArray BBB AAA []"
> method_supers(MyArray,:to_s)
=> ["MyArray#to_s", "BBB#to_s", "AAA#to_s", "Array#to_s", ...]