Sha256: a0509d265237cff64fe2e7550e3a450476bb6c94d491c7296f9c5718ceac51f1

Contents?: true

Size: 1014 Bytes

Versions: 1

Compression:

Stored size: 1014 Bytes

Contents

module Gummi
  module RepositoryLayer
    module Repository
      class Result

        attr_reader :took, :total, :hits

        def initialize(search_result, converter)
          @search_result  = search_result
          @took      = @search_result.took
          @documents = @search_result.documents
          @converter = converter
        end

        def facets
          @facets ||= begin
            response.facets.each_with_object({}) do |(name, content), facets|
              facets[name] = Hash[content.terms.map(&:values)]
            end
          end
        end

        def total
          documents.total_entries
        end

        def records
          @records ||= begin
            # Passing through the Leaflet Collection, but converting the records.
            documents.map! { |document| converter.db_instance_to_entity(document) }
            documents
          end
        end

        private

        attr_reader :search_result, :converter, :documents

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gummi-0.2.0 lib/gummi/repository_layer/repository/result.rb