For the impatient:
[
Class#inheritedis a] Callback invoked whenever a subclass of the current class is
The long story: Today I stumbled over a piece of code like the following:
class Foo
class << self
def inherited(subclass)
$subclasses << subclass
end
end
end
The interesting thing is that this was the only occurrence of inherited in the entire codebase, so I instantly assumed some Ruby magic and went over to RubyDoc, but didn’t find anything there. After some additional Googling I found a mailing list post which confirmed that inherited is a method on Class, but it still didn’t explain why it didn’t show up on RubyDoc.
It turned out that apparently RubyDoc only shows public methods, which IMO is pretty confusing (at least it was for me). I finally found my missing method on ApiDock, which does show private methods.