Class: Net::HTTPResponse
Overview
:nodoc:
Instance Method Summary collapse
-
#from_json ⇒ Object
Converts the result from JSON if
okay?
returns true; otherwise returns nil. -
#okay? ⇒ Boolean
Returns false if the server encountered an error, true otherwise.
-
#or_raise! ⇒ Object
Raises an exception if the request failed.
Instance Method Details
#from_json ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/okay/http.rb', line 34 def from_json return nil unless okay? require "json" JSON.parse(body) end |
#okay? ⇒ Boolean
Returns false if the server encountered an error, true otherwise.
14 15 16 17 18 19 |
# File 'lib/okay/http.rb', line 14 def okay? self.value true rescue Net::HTTPExceptions false end |
#or_raise! ⇒ Object
Raises an exception if the request failed. (A fatal equivalent of okay?
)
22 23 24 25 |
# File 'lib/okay/http.rb', line 22 def or_raise! self.value self end |