Suppose I want to determine if Admin inherits from ActiveRecord::Base. One way is to do this is Admin.new.kind_of? ActiveRecord::Base, but that instantiates an unused Admin object.
Is there an easy way of doing this without creating an Admin object?
Thanks
Sure, just compare the two classes:
It is interesting to note that while
Module#<will returntrueifAdmininherits fromAR::Base, it will returnfalseornilif that’s not the case.falsemeans that it is the otherway around, whilenilis for unrelated classes (e.g.String < Rangereturnsnil).