0

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
parlia
  • 37
  • 1
  • 4

1 Answers1

5

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
  • 28,535
  • 12
  • 89
  • 91