Skip to content

fix: more flexible polymorphic types lookup#1424

Closed
bf4 wants to merge 3 commits intov0-11-devfrom
v0-11-more_flexible_polymorphic_types
Closed

fix: more flexible polymorphic types lookup#1424
bf4 wants to merge 3 commits intov0-11-devfrom
v0-11-more_flexible_polymorphic_types

Conversation

@bf4
Copy link
Collaborator

@bf4 bf4 commented Dec 31, 2023

Includes:

  • fix: more flexible polymorphic types lookup
  • refactor: lookup polymorphic types only once

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 force-pushed the v0-11-more_flexible_polymorphic_types branch from a140f14 to 7915c04 Compare December 31, 2023 11:56
next unless Module === klass
if ActiveRecord::Base > klass
is_active_record_inspectable = ActiveRecord::Base > klass
is_active_record_inspectable &&= klass.respond_to?(:reflect_on_all_associations, true)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lgebhardt I'll add a test for this. I'm testing against our app on this branch right now and looks good

end
end
@poly_hash[_polymorphic_name.to_sym]
JSONAPI::Relationship.polymorphic_types(_polymorphic_name.to_sym)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lgebhardt is a refactor included in the PR as a separate commit

end
@poly_hash[name.to_sym]
@poly_hash.fetch(name.to_sym) do
klass = name.classify.safe_constantize
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fallback strategy I'm trying

@bf4 bf4 force-pushed the v0-11-more_flexible_polymorphic_types branch from 7915c04 to 338303a Compare January 17, 2024 07:48
bf4 added 3 commits January 18, 2024 08:11
they pass on v-11-dev

I'm going to look into the existing lookup warnings

now
```
[POLYMORPHIC TYPE NOT FOUND] No polymorphic types found for fileable
[POLYMORPHIC TYPE] No polymorphic types found for FilePropertiesResource fileable
[POLYMORPHIC TYPE NOT FOUND] No polymorphic types found for respondent
[POLYMORPHIC TYPE] No polymorphic types found for QuestionResource respondent
[POLYMORPHIC TYPE NOT FOUND] No polymorphic types found for respondent
[POLYMORPHIC TYPE] No polymorphic types found for AnswerResource respondent
[POLYMORPHIC TYPE NOT FOUND] No polymorphic types found for keepable
[POLYMORPHIC TYPE] No polymorphic types found for KeeperResource keepable
```
@bf4 bf4 force-pushed the v0-11-more_flexible_polymorphic_types branch from 338303a to cc46f11 Compare January 18, 2024 14:11
@bf4 bf4 mentioned this pull request Jan 18, 2024
12 tasks
@lgebhardt
Copy link
Contributor

Supplanted by #1433

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