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

refactor: separate polymorphic functions #1433

Merged
merged 4 commits into from
Jan 19, 2024

Conversation

bf4
Copy link
Collaborator

@bf4 bf4 commented Jan 18, 2024

  • refactor: polymorphic lookups to utility module
  • refactor: lookup polymorphic types only once

Extracted from #1424
since it hints at a general usefulness of having a dedication function
module for handling polymorphic lookups.

All Submissions:

  • I've checked to ensure there aren't other open Pull Requests for the same update/change.
  • I've submitted a ticket for my issue if one did not already exist.
  • My submission passes all tests. (Please run the full test suite locally to cut down on noise from travis failures.)
  • I've used Github auto-closing keywords in the commit message or the description.
  • I've added/updated tests for this change.

New Feature Submissions:

  • I've submitted an issue that describes this feature, and received the go ahead from the maintainers.
  • My submission includes new tests.
  • My submission maintains compliance with JSON:API.

Bug fixes and Changes to Core Features:

  • I've included an explanation of what the changes do and why I'd like you to include them.
  • I've provided test(s) that fails without the change.

Test Plan:

Reviewer Checklist:

  • Maintains compliance with JSON:API
  • Adequate test coverage exists to prevent regressions

@bf4 bf4 requested a review from lgebhardt January 19, 2024 00:02

module JSONAPI
module Utils
extend self
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 named Utils because my intention is for this to be a collection of functions which may not have an obvious theme or place on their own.
Called extend self instead of module_function to declare that this module is intended to hold functions, not to be included anywhere.

@polymorphic_types_lookup ||= build_polymorphic_types_lookup
end

def build_polymorphic_types_lookup
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now refactoring the way we build the polymorphic lookup doesn't add any interface to the JSONAPI::Relationship nor JSONAPI::Resource

@lgebhardt lgebhardt merged commit 76ef777 into v0-11-dev Jan 19, 2024
39 checks passed
@lgebhardt lgebhardt deleted the v-11-refactor_polymorphic_inference branch January 19, 2024 22:35
lgebhardt added a commit that referenced this pull request Apr 18, 2024
* refactor: lookup polymorphic types only once

* refactor: polymorphic lookups to utility module

* refactor: separate polymorphic functions

* Refactor into PolymorphicTypesLookup

---------

Co-authored-by: lgebhardt <larry@cerebris.com>
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 this pull request may close these issues.

2 participants