Class: Ecoportal::API::Common::BatchResponse
- Inherits:
-
Object
- Object
- Ecoportal::API::Common::BatchResponse
- Defined in:
- lib/ecoportal/api/common/batch_response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(status, body, result = nil) ⇒ BatchResponse
constructor
A new instance of BatchResponse.
- #print_pretty ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(status, body, result = nil) ⇒ BatchResponse
Returns a new instance of BatchResponse.
7 8 9 10 11 |
# File 'lib/ecoportal/api/common/batch_response.rb', line 7 def initialize(status, body, result = nil) @status = HTTP::Response::Status.new(status) @body = body @result = result end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'lib/ecoportal/api/common/batch_response.rb', line 5 def body @body end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
5 6 7 |
# File 'lib/ecoportal/api/common/batch_response.rb', line 5 def result @result end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/ecoportal/api/common/batch_response.rb', line 5 def status @status end |
Instance Method Details
#each(&block) ⇒ Object
17 18 19 |
# File 'lib/ecoportal/api/common/batch_response.rb', line 17 def each(&block) [*@result].each(&block) end |
#print_pretty ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/ecoportal/api/common/batch_response.rb', line 21 def print_pretty if success? each(&:print_pretty) else puts "Request failed." end end |
#success? ⇒ Boolean
13 14 15 |
# File 'lib/ecoportal/api/common/batch_response.rb', line 13 def success? status.success? end |