lib/active_remote/serialization.rb in active_remote-1.5.5 vs lib/active_remote/serialization.rb in active_remote-1.5.6
- old
+ new
@@ -6,16 +6,16 @@
klass.class_eval do
include ::ActiveRemote::Serializers::JSON
end
end
- # Examine the last response and add any errors to our internal errors
- # list.
+ # Examine the given response and add any errors to our internal errors
+ # list. If no response is given, use the last response.
#
- def add_errors_from_response
- return unless last_response.respond_to?(:errors)
+ def add_errors_from_response(response=self.last_response)
+ return unless response.respond_to?(:errors)
- last_response.errors.each do |error|
+ response.errors.each do |error|
if error.respond_to?(:message)
errors.add(error.field, error.message)
elsif error.respond_to?(:messages)
error.messages.each do |message|
errors.add(error.field, message)