Within a method at runtime, is there a way to know if that method has been called via super
in a subclass? E.g.
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!"
How could I write via_super?
, or, if necessary, via_super?(:bar)
?
SuperDetector
. – Thundering