Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle picking most specific class #66

Open
ajtucker opened this issue Feb 25, 2025 · 0 comments · May be fixed by #67
Open

Handle picking most specific class #66

ajtucker opened this issue Feb 25, 2025 · 0 comments · May be fixed by #67

Comments

@ajtucker
Copy link
Contributor

JSON responses are deserialized into "wrapper" classes and where no wrapper class is given, a class is chosen by looking for a Ruby class with the same name as the @type of the resource.

However, resources will often be decorated with more than one type, for example if there is a subclass relationship and this is made explicit in the data.

The current approach is to just take the first class that matches the name of the first resource type.

This leads to indeterminacy if we make use of a type hierarchy in the Ruby model classes, as we may pick an arbitrary class if more than one type is given.

Ruby 2.7 still only has rudimentary support for classes, but we should be able to discount any wrapper classes that are the supertype of any other wrapper class found for the given list of types of the resource.

@ajtucker ajtucker linked a pull request Feb 25, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant