Skip to content

Instantly share code, notes, and snippets.

@bretweinraub
Created November 12, 2010 19:18
Show Gist options
  • Save bretweinraub/674529 to your computer and use it in GitHub Desktop.
Save bretweinraub/674529 to your computer and use it in GitHub Desktop.
class Foo < ActiveRecord::Base
end
class Class
def inherits_from?(klass)
raise ArgumentError.new("argument must be of type Class") unless klass.is_a? Class
if klass == self
true
elsif self.superclass.is_a? Class
self.superclass.inherits_from? klass
else
false
end
end
end
Foo.inherits_from? ActiveRecord::Base
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment