I have a gem I want to decouple from activerecord to be able to use the orm/db of the application it is installed in. There is a gem ‘orm_adapter’ that seems to handle much, reducing the code I need to add. One issue down.
However, I’m not certain about how to go specifying the 1 model I have. I can think of two ways to go about this both of which my search terms have not been refined enough to find readily useful guides:
1) Make the generator (which already copies a migration over to the app) determine what ORM is being used, and behave accordingly.
2) Find some way of abstracting the model declaration so that it is generic enough to work with whatever app it installed in. I’ve looked at ActiveModel, but I don’t know. This is something I need to persist for the application it is installed in.
My basic question is, how is this done? How have others handled this? My specific situation is I now have several apps using Activerecord or DataMapper that I’m adding common functionality by a gem, and this 1 model which needs persistance and access by the application. I’m not sure about how to exactly go about this, but it seems that it would be something already solved elsewhere, I’m just not aware of the solution.
Adding ‘stuff’ to the generator seems to work, so far