problem with inheritance and "self"

G

Giles Bowkett

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?
 
G

Giles Bowkett

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top