Class: TempoIQ::HttpResult
- Inherits:
-
Object
- Object
- TempoIQ::HttpResult
- Defined in:
- lib/tempoiq/remoter/http_result.rb
Constant Summary collapse
- OK =
200- MULTI =
207- BAD_REQUEST =
400- UNAUTHORIZED =
401- NOT_FOUND =
404- UNPROCESSABLE =
422- INTERNAL =
500
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
-
#initialize(code, headers, body) ⇒ HttpResult
constructor
A new instance of HttpResult.
- #on_success(&block) ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(code, headers, body) ⇒ HttpResult
Returns a new instance of HttpResult.
24 25 26 27 28 |
# File 'lib/tempoiq/remoter/http_result.rb', line 24 def initialize(code, headers, body) @code = code @headers = headers @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
22 23 24 |
# File 'lib/tempoiq/remoter/http_result.rb', line 22 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
22 23 24 |
# File 'lib/tempoiq/remoter/http_result.rb', line 22 def code @code end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
22 23 24 |
# File 'lib/tempoiq/remoter/http_result.rb', line 22 def headers @headers end |
Instance Method Details
#on_success(&block) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/tempoiq/remoter/http_result.rb', line 30 def on_success(&block) if success? yield self else raise HttpException.new(self), "HTTP returned non-success response: #{code}, #{body}" end end |
#success? ⇒ Boolean
38 39 40 |
# File 'lib/tempoiq/remoter/http_result.rb', line 38 def success? code / 100 == 2 end |