class Elasticsearch::Resources::ResponseFactory
Attributes
action[R]
resource[R]
response[R]
Public Class Methods
new(resource:, action:, response:)
click to toggle source
# File lib/elasticsearch/resources/response_factory.rb, line 6 def initialize(resource:, action:, response:) @resource = resource @action = action @response = response end
Public Instance Methods
build()
click to toggle source
# File lib/elasticsearch/resources/response_factory.rb, line 12 def build case action when :get build_get when :search build_search else response end end
build_get()
click to toggle source
# File lib/elasticsearch/resources/response_factory.rb, line 23 def build_get DocumentFactory.new( content: response, resources: resources_for(response) ).build end
build_search()
click to toggle source
# File lib/elasticsearch/resources/response_factory.rb, line 30 def build_search raw_documents = response['hits']['hits'] raw_documents.collect do |raw_document| DocumentFactory.new( content: raw_document, resources: resources_for(raw_document) ).build end end
resources_for(content)
click to toggle source
# File lib/elasticsearch/resources/response_factory.rb, line 40 def resources_for(content) { cluster: resource.find_cluster, index: resource.find_index(index: content['_index']), type: resource.find_type(index: content['_index'], type: content['_type']) } end