views:

93

answers:

1

Let's say I have a model class called Project, but instead of this:

class Project < ActiveRecord::Base

I wanted to write this:

class Project < ORM

so that the specific ORM implementation is not present in my model class.

How would I need to write my ORM class so that the Project class above is able to act as a subclass of ActiveRecord::Base but without specifically subclassing it?

Would I simply say:

class ORM < ActiveRecord::Base

and then Project would be a subclass of ActiveRecord::Base just the same as if I had written:

class Project < ActiveRecord::Base
+5  A: 

Possibly an easier way to do this would be to just assign ActiveRecord::Base:

ORM = ActiveRecord::Base

class Project < ORM
end

Then, if you wanted to swap to a different implementation later, you could just change the assignment to ORM.

Yehuda Katz