Class: Elasticated::BulkRequest::Response

Inherits:
Object
  • Object
show all
Includes:
Mixins::Inspectionable
Defined in:
lib/elasticated/bulk_request/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Mixins::Inspectionable

#inspect

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



17
18
19
# File 'lib/elasticated/bulk_request/response.rb', line 17

def errors
  @errors
end

#itemsObject

Returns the value of attribute items.



17
18
19
# File 'lib/elasticated/bulk_request/response.rb', line 17

def items
  @items
end

#tookObject

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?

Returns:

  • (Boolean)


19
20
21
# File 'lib/elasticated/bulk_request/response.rb', line 19

def errors?
  !!errors
end

#text_for_inspectObject



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