-
Notifications
You must be signed in to change notification settings - Fork 897
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
Generic object enhancement. #15893
Generic object enhancement. #15893
Conversation
Thanks for the update @lfu! 👍 |
0c9113a
to
97d2786
Compare
cc @bzwei |
97d2786
to
61e0fbe
Compare
Instead of converting all attribute names to string |
Instead of inserting |
@bzwei Jsonb column has all keywords stored in String format. So I think String format may be more appropriate. |
Is it a valid use case that "It is possible that the generic object has the definition in DB but somehow the definition object does not exist"? In a production it is a penalty to validate for every method call. If it is for the debugging purpose then the code should exist only in debug mode (although I don't know how) |
61e0fbe
to
ad8a8ee
Compare
app/models/generic_object.rb
Outdated
properties.delete(name.to_s) | ||
save! | ||
|
||
val |
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.
Instead of creating a local variable you can use tap
here to return the result of _property_getter(name)
_property_getter(name).tap do
properties.delete(name.to_s)
save!
end
@lfu Please review this PR description to make sure it is still accurate. |
… and associations.
ad8a8ee
to
af30158
Compare
@bzwei PTAL |
app/models/generic_object.rb
Outdated
selected = objs.select { |obj| obj.kind_of?(klass) } | ||
properties[name] = (properties[name] + selected.pluck(:id)).uniq if selected | ||
save | ||
return unless properties_changed? |
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.
Do we need to explicitly check for properties_changed?
?. I think save!
internally does the check.
af30158
to
2009663
Compare
Checked commits lfu/manageiq@71794cf~...2009663 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
Some changes to generic object.
@miq-bot assign @gmcculloug
@miq-bot add_label enhancement
cc @jntullo