Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/json_api_client/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ def save
if last_result_set.has_errors?
last_result_set.errors.each do |error|
if error.source_parameter
errors.add(self.class.key_formatter.unformat(error.source_parameter), error.title || error.detail)
errors.add(self.class.key_formatter.unformat(error.source_parameter), message_for(error))
else
errors.add(:base, error.title || error.detail)
errors.add(:base, message_for(error))
end
end
false
Expand All @@ -431,6 +431,14 @@ def save
end
end

def message_for(error)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this belong as an instance method? If it's extracted here, perhaps it belongs as a class method for this resource. It can still be overridden by a child class if you so choose.

if error.title && error.detail
"#{error.title} - #{error.detail}"
else
error.title || error.detail
end
end

# Try to destroy this resource
#
# @return [Boolean] Whether or not the destroy succeeded
Expand Down