【发布时间】:2013-06-21 19:20:11
【问题描述】:
我正在开发一个具有一些复杂类/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", ...]
【问题讨论】:
-
如果有人想到更好的标题,请告诉我。
标签: ruby inheritance reflection mixins super