Sha256: 67ea5e48d452df3002932e64659883ae5abb5d7c7bf645227a6ffd8705475a38

Contents?: true

Size: 1.06 KB

Versions: 18

Compression:

Stored size: 1.06 KB

Contents

module Gummi
  module DbLayer
    module Document
      module Search
        class Result

          attr_reader :took, :total, :hits, :facets

          def initialize(response, converter, per_page, page)
            @success   = !!response
            @response  = Hashie::Mash.new response
            @took      = @response.took
            @total     = @response.hits.total if @response.hits
            @hits      = @response.hits.hits  if @response.hits
            @facets    = @response.facets || Hashie::Mash.new
            @converter = converter
            @per_page  = per_page
            @page      = page
          end

          def documents
            @documents ||= begin
              documents = Array(converter.hits_to_documents(hits)) if hits
              Leaflet::Collection.new documents, total: total, page: page, per_page: per_page
            end
          end

          def success?
            @success
          end

          private

          attr_reader :response, :converter, :per_page, :page, :hits

        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
gummi-1.0.10 lib/gummi/db_layer/document/search/result.rb
gummi-1.0.9 lib/gummi/db_layer/document/search/result.rb
gummi-1.0.8 lib/gummi/db_layer/document/search/result.rb
gummi-1.0.7 lib/gummi/db_layer/document/search/result.rb
gummi-1.0.6 lib/gummi/db_layer/document/search/result.rb
gummi-1.0.5 lib/gummi/db_layer/document/search/result.rb
gummi-1.0.4 lib/gummi/db_layer/document/search/result.rb
gummi-0.3.16 lib/gummi/db_layer/document/search/result.rb
gummi-1.0.3 lib/gummi/db_layer/document/search/result.rb
gummi-1.0.2 lib/gummi/db_layer/document/search/result.rb
gummi-1.0.0 lib/gummi/db_layer/document/search/result.rb
gummi-0.3.14 lib/gummi/db_layer/document/search/result.rb
gummi-0.3.13 lib/gummi/db_layer/document/search/result.rb
gummi-0.3.12 lib/gummi/db_layer/document/search/result.rb
gummi-0.3.11 lib/gummi/db_layer/document/search/result.rb
gummi-0.3.10 lib/gummi/db_layer/document/search/result.rb
gummi-0.3.9 lib/gummi/db_layer/document/search/result.rb
gummi-0.3.8 lib/gummi/db_layer/document/search/result.rb