Class inherits from
I wanted to know if a class was an Active Record class. I couldn’t find an easy way to do it in Ruby so I monkey patches the Class object like so (assuming Person is an active record model object).
class Class def inherits_from?(klass, me=self) return false if me.nil? return true if me == klass inherits_from? klass, me.superclass end end >> Person.inherits_from? ActiveRecord::Base => true