Sha256: 03bde8578497d2d6500fb4cc9813a393736cea4aa21c1c12f584ef09ee7f5f0f

Contents?: true

Size: 783 Bytes

Versions: 1

Compression:

Stored size: 783 Bytes

Contents

module Elasticsearch
  module Model
    module Response

      # Encapsulates the collection of documents returned from Elasticsearch
      #
      # Implements Enumerable and forwards its methods to the {#results} object.
      #
      class Results
        include Base
        include Enumerable

        extend  Support::Forwardable
        forward :results, :each, :empty?, :size, :slice, :[], :to_a, :to_ary

        # @see Base#initialize
        #
        def initialize(klass, response, options={})
          super
        end

        # Returns the {Results} collection
        #
        def results
          # TODO: Configurable custom wrapper
          @results  = response.response['hits']['hits'].map { |hit| Result.new(hit) }
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
elasticsearch-model-0.1.0.rc1 lib/elasticsearch/model/response/results.rb