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
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