在运行时的方法中,有没有办法知道该方法是否已super
在子类中调用?例如
module SuperDetector
def via_super?
# what goes here?
end
end
class Foo
include SuperDetector
def bar
via_super? ? 'super!' : 'nothing special'
end
end
class Fu < Foo
def bar
super
end
end
Foo.new.bar # => "nothing special"
Fu.new.bar # => "super!"
我怎么能写via_super?
,或者,如果有必要,via_super?(:bar)
?