Looking at the AR code and just focusing on sti_name and instantiate .. it seems you might have enough for the monkey to establish these two methods.
I have no experience with this, but it does not look incredibly complicated. Here's what instantiate looks like:
def instantiate(record) model = find_sti_class(record[inheritance_column]).allocate model.init_with('attributes' => record) model end
Ideally, you want to scan the code for anything that refers to something like record[inheritance_column] or just inheritance_column , and draw your own matching code there. Just a quick look, and it seems that it is not used in many places.
I would say that you are trying to make it possible :), but you will need test cases for the base instance + things in which associations are involved to make sure that AR can find and build the correct SQL for different cases.
This is clear, although the AR was not built with what you are trying to recall, since the use of inheritance_column in the code has not been explicitly deleted anywhere. So why you need to delve more into the code.
Casper
source share