Problem with inheritance and "self"

I have three classes.

AbstractThing
BlueThing
RedThing

inside AbstractThing:

def self.get
  self.find(:first)
end

(yup, it's a Rails app)

I want the DB to only have tables for blue_things and red_things --
but currently, this method gives me a search for abstract_things. The
reason is, the method dispatch pops up to super, finds the method, and
away we go.

How do I redefine this method so I only have to define it inside
AbstractThing, yet when I do, the method dispatch works in such a way
that BlueThing will look for blue_things in the DB, but do it using
AbstractThing's #get() method? In other words -- how do I get the
method to act not from within the superclass which defines it, but the
specific class which uses it?

···

--
Giles Bowkett
http://www.gilesgoatboy.org


http://gilesgoatboy.blogspot.com

Just want to say, this turned out to be a Rails problem, not a Ruby
thing at all.

···

On 2/6/07, Giles Bowkett <gilesb@gmail.com> wrote:

I have three classes.

AbstractThing
BlueThing
RedThing

inside AbstractThing:

def self.get
  self.find(:first)
end

(yup, it's a Rails app)

I want the DB to only have tables for blue_things and red_things --
but currently, this method gives me a search for abstract_things. The
reason is, the method dispatch pops up to super, finds the method, and
away we go.

How do I redefine this method so I only have to define it inside
AbstractThing, yet when I do, the method dispatch works in such a way
that BlueThing will look for blue_things in the DB, but do it using
AbstractThing's #get() method? In other words -- how do I get the
method to act not from within the superclass which defines it, but the
specific class which uses it?

--
Giles Bowkett
http://www.gilesgoatboy.org
http://gilesbowkett.blogspot.com
http://gilesgoatboy.blogspot.com

--
Giles Bowkett
http://www.gilesgoatboy.org

http://gilesgoatboy.blogspot.com