fast_jsonapi
fast_jsonapi copied to clipboard
WIP: make belongs_to polymorphic use `id_method_name`
fixes #382
This is more or less a WIP to see what you guys say about this.
Some remarks:
- There could be a short cut to not fetch the associated record in case of
belongs_to
without a object block. In this specific case it might be enough to use thexxx_type
column and&:id_method_name
on the parent. This would remove the need to instantiate the associated record in that case. Though then thefetch_id
method could not be used and thebelongs_to
case would be a completely separated case. -
run_key_transform
is not yet cached (like in other methods)
What do you say about this in general?
I could think of a second way to make belongs_to
have a complete different logic, which might speed belongs_to
up though (if there is no need to fetch the association), but not sure if this is the way to go or if this makes the class too complex and if the xxx_type
column is enough to get the class (or if there are some edge cases where this does not work).
This should probably also be updated to work with has_one