Check before update attribute of basemodel #93
Conversation
send("#{method_name}=", value) | ||
invoke_name = "#{override_raw_attributes[method_name] ? override_raw_attributes[method_name] : method_name}=" | ||
if respond_to?(invoke_name) | ||
send(invoke_name, value) |
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.
Probably need a else
or rescue
here that logs a debug message saying it couldn't write to a specific attribute name.
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.
Done. Also added a spec test.
@@ -82,10 +82,11 @@ def self.create(*args) | |||
def update_attributes!(attributes) | |||
@api.patch(url, attributes.to_json) | |||
attributes.each do |method_name, value| | |||
if override_raw_attributes[method_name] | |||
send("#{override_raw_attributes[method_name]}=", value) | |||
invoke_name = "#{override_raw_attributes[method_name] ? override_raw_attributes[method_name] : method_name}=" |
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.
override_raw_attributes[method_name] ? override_raw_attributes[method_name] : method_name
can be simplified to:
override_raw_attributes[method_name] || method_name
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.
👍
done!
Checked commit jameswnl@5f85374 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
@miq-bot remove_label wip |
This is to fix https://bugzilla.redhat.com/show_bug.cgi?id=1445995
When caller passes in attributes that client doesn't know, even though Tower succeed in the call, client is blown up.
@miq-bot add_labels wip, bug