Ruby get inheriting class

Posted by Brian D. on Stack Overflow See other posts from Stack Overflow or by Brian D.
Published on 2010-04-11T00:54:48Z Indexed on 2010/04/11 1:03 UTC
Read the original article Hit count: 281

Filed under:
|

I'm working on creating my first plugin for rails. I'm still pretty new to ruby and I was wondering if its possible to get the inheriting class?

For example, I'm trying to create a plugin that will allow unit testing and functional testing when you are not using migrations. What I'm trying to do is initialize a class variable named controller to be initialized to the type of controller that is being tested.

If I have a base class ControllerTest:

class ControllerTest < Test::Unit::TestCase
  attr_accessor :controller

  def initialize
    super
    @controller = "call function that will find the inheriting classes name and create an instance of that controller type."
  end
end

So what I'm currently stuck on is getting the name of the inheriting class. Is this possible? And if not, does anyone know another way on how I could go about implementing this?

Thanks in advance.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about inheritance