Updating success logic

Updating the definition of SUCCESS response code to be 200 OK or 201
Continue. Error is anything that isn't success. This helps flag
conditions like an unsuccessful update (return code 304) which the
library would have flagged as success earlier
This commit is contained in:
Sudipta Chatterjee 2015-04-10 16:12:37 -07:00
parent 0003e564b1
commit 1cea86609b
1 changed files with 7 additions and 3 deletions

View File

@ -79,13 +79,13 @@ module Google
end
##
# Check if request failed
# Check if request failed - which is anything other than 200/201 OK
#
# @!attribute [r] error?
# @return [TrueClass, FalseClass]
# true if result of operation is an error
def error?
return self.response.status >= 400
return !self.success?
end
##
@ -95,7 +95,11 @@ module Google
# @return [TrueClass, FalseClass]
# true if result of operation was successful
def success?
return !self.error?
if self.response.status == 200 || self.response.status == 201
return true
else
return false
end
end
##