Class: Elasticated::BulkRequest::Response
- Inherits:
-
Object
- Object
- Elasticated::BulkRequest::Response
- Includes:
- Mixins::Inspectionable
- Defined in:
- lib/elasticated/bulk_request/response.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#items ⇒ Object
Returns the value of attribute items.
-
#took ⇒ Object
Returns the value of attribute took.
Class Method Summary collapse
Instance Method Summary collapse
- #errors? ⇒ Boolean (also: #error?)
- #text_for_inspect ⇒ Object
Methods included from Mixins::Inspectionable
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
17 18 19 |
# File 'lib/elasticated/bulk_request/response.rb', line 17 def errors @errors end |
#items ⇒ Object
Returns the value of attribute items.
17 18 19 |
# File 'lib/elasticated/bulk_request/response.rb', line 17 def items @items end |
#took ⇒ Object
Returns the value of attribute took.
17 18 19 |
# File 'lib/elasticated/bulk_request/response.rb', line 17 def took @took end |
Class Method Details
.parse(elasticsearch_response) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/elasticated/bulk_request/response.rb', line 7 def self.parse(elasticsearch_response) response = new response.took = elasticsearch_response['took'] response.errors = elasticsearch_response['errors'] response.items = elasticsearch_response['items'].map do |elasticsearch_item| ResponseItem.parse elasticsearch_item end response end |
Instance Method Details
#errors? ⇒ Boolean Also known as: error?
19 20 21 |
# File 'lib/elasticated/bulk_request/response.rb', line 19 def errors? !!errors end |
#text_for_inspect ⇒ Object
24 25 26 27 28 |
# File 'lib/elasticated/bulk_request/response.rb', line 24 def text_for_inspect text = (items.count == 1) ? "#{items.count} item" : "#{items.count} items" text = errors? ? "#{text}, with errors" : "#{text}, no errors" text end |