-
Notifications
You must be signed in to change notification settings - Fork 898
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
Drop Supports' unsupports variable #22898
Conversation
ae70c63
to
8c5f663
Compare
8c5f663
to
4d8dd9e
Compare
update:
|
4d8dd9e
to
9dc6541
Compare
update:
|
up-wip: still waiting on #22976 - just un-WIPing to show this is good to go |
3ade819
to
6aa38cc
Compare
6aa38cc
to
f791e24
Compare
@Fryguy anything special to push this forward? let me know if you want me to split into 2 PRs (for each commit) |
f791e24
to
065be55
Compare
update:
|
065be55
to
84675ca
Compare
Part of ManageIQ/manageiq#22898 (as a followup) Introduced by ManageIQ/manageiq-providers-ibm_power_hmc#153 You can not have a return in a block. It causes a LongJump error Besides, it tries to return from inside the calling block - not what we want.
Part of ManageIQ/manageiq#22898 (as a followup) Introduced by ManageIQ#103 You can not have a return in a block. It causes a LongJump error Besides, it tries to return from inside the calling block - not what we want.
Part of ManageIQ/manageiq#22898 (as a followup) Introduced by ManageIQ#103 You can not have a return in a block. It causes a LongJump error Besides, it tries to return from inside the calling block - not what we want.
Part of ManageIQ/manageiq#22898 (as a followup) Introduced by ManageIQ#659 You can not have a return in a block. It causes a LongJump error Besides, it tries to return from inside the calling block - not what we want. Fixes a missed unsupported reason check
84675ca
to
8bb9418
Compare
8bb9418
to
b0768b7
Compare
update:
All repos are all ready for this commit |
b0768b7
to
ce9c449
Compare
Checked commit kbrock@ce9c449 with ruby 3.1.5, rubocop 1.56.3, haml-lint 0.51.0, and yamllint |
update:
@Fryguy Any ideas how to get this over the line? Probably merged 45 PRs to get this far. (though only see 25 listed here). |
def check_supports(feature, instance:) | ||
instance.send(:unsupported).delete(feature) | ||
|
||
# query the class if the feature is supported or not | ||
def unsupported_reason(feature, instance: self) | ||
# undeclared features are not supported | ||
value = supports_features[feature.to_sym] | ||
|
||
if value.respond_to?(:call) | ||
begin | ||
# for class level supports, blocks are not evaluated and assumed to be true | ||
result = instance.instance_eval(&value) unless instance.kind_of?(Class) | ||
# if no errors yet but result was an error message | ||
# then add the error | ||
if !instance.send(:unsupported).key?(feature) && result.kind_of?(String) | ||
instance.send(:unsupported_reason_add, feature, result) | ||
end | ||
result if result.kind_of?(String) |
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.
This is the crux of this pr.
Before
When asked, clear unsupported
and then setting it with new value.
After
return the value and don't use unsupported
Overview
Drop class level
Model.unsupported
. It is modified by everyModel.supports?(:feature)
call and has a race condition.Before
Model.supports_features
hash once at startup. Not modified again.supports?(:feature)
fromsupports_features
hash.Model.unsupported
hash every time.unsupported
After
Model.supports_features
hash once at startup. Not modified again.supports?(:feature)
fromsupports_features
hash.unsupported_reason
block if necessary, but don't store results in class level variables.Requirements
Depends upon:
supports :feature
returns aString
- see dependencies for aboveprecursor: