-
Notifications
You must be signed in to change notification settings - Fork 530
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
fix: more flexible polymorphic types lookup #1424
Conversation
a140f14
to
7915c04
Compare
@@ -90,14 +90,37 @@ def self.polymorphic_types(name) | |||
@poly_hash ||= {}.tap do |hash| | |||
ObjectSpace.each_object do |klass| | |||
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 | ||
end | ||
end | ||
end | ||
@poly_hash[name.to_sym] | ||
@poly_hash.fetch(name.to_sym) do | ||
klass = name.classify.safe_constantize |
There was a problem hiding this comment.
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
7915c04
to
338303a
Compare
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 ```
338303a
to
cc46f11
Compare
Supplanted by #1433 |
Includes:
All Submissions:
New Feature Submissions:
Bug fixes and Changes to Core Features:
Test Plan:
Reviewer Checklist: